Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-07-02 11:43:29
Exec Total Coverage
Lines: 8572 12306 69.7%
Functions: 74 107 69.2%
Branches: 5487 10197 53.8%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #include "allegro/file.h"
12 #include "base/util.h"
13 #include "base/zapp.h"
14 #include <filesystem>
15 #include <stdio.h>
16 #include <string.h>
17
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 #include <string>
18 #include <map>
19 #include <vector>
20 #include <assert.h>
21 #include <fmt/format.h>
22
23
24 #include "metadata/sigs/devsig.h.sig"
25 #include "metadata/sigs/compilersig.h.sig"
26 #include "metadata/versionsig.h"
27 #include "base/zc_alleg.h"
28 #include "base/zdefs.h"
29 #include "base/colors.h"
30 #include "tiles.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "defdata.h"
34 #include "subscr.h"
35 #include "font.h"
36 #include "zc/zc_custom.h"
37 #include "sfx.h"
38 #include "md5.h"
39 #include "zc/ffscript.h"
40 #include "particles.h"
41 #include "dialog/alert.h"
42
43 #ifdef __EMSCRIPTEN__
44 #include "base/emscripten_utils.h"
45 #endif
46
47 //FFScript FFCore;
48 extern FFScript FFCore;
49 extern ZModule zcm;
50 extern zcmodule moduledata;
51 extern uint8_t __isZQuest;
52 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
53 extern particle_list particles;
54 extern void setZScriptVersion(int32_t s_version);
55 //FFSCript FFEngine;
56
57 int32_t temp_ffscript_version = 0;
58 static bool read_ext_zinfo = false, read_zinfo = false;
59 static bool loadquest_report = false;
60 static char const* loading_qst_name = NULL;
61 static byte loading_qst_num = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 // extern bool debug;
79 extern int32_t hero_animation_speed; //lower is faster animation
80 extern std::vector<mapscr> TheMaps;
81 extern zcmap *ZCMaps;
82 extern MsgStr *MsgStrings;
83 extern DoorComboSet *DoorComboSets;
84 extern dmap *DMaps;
85 extern std::vector<newcombo> combobuf;
86 extern byte *colordata;
87 //extern byte *tilebuf;
88 extern tiledata *newtilebuf;
89 extern byte *trashbuf;
90 extern itemdata *itemsbuf;
91 extern wpndata *wpnsbuf;
92 extern comboclass *combo_class_buf;
93 extern guydata *guysbuf;
94 extern ZCHEATS zcheats;
95 extern zinitdata zinit;
96 extern char palnames[MAXLEVELS][17];
97 extern int32_t memrequested;
98 extern char *byte_conversion(int32_t number, int32_t format);
99 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
100 38 string zScript;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
38 std::map<int32_t, script_slot_data > ffcmap;
102 38 std::map<int32_t, script_slot_data > globalmap;
103 38 std::map<int32_t, script_slot_data > genericmap;
104 38 std::map<int32_t, script_slot_data > itemmap;
105 38 std::map<int32_t, script_slot_data > npcmap;
106 38 std::map<int32_t, script_slot_data > ewpnmap;
107 38 std::map<int32_t, script_slot_data > lwpnmap;
108 38 std::map<int32_t, script_slot_data > playermap;
109 38 std::map<int32_t, script_slot_data > dmapmap;
110 38 std::map<int32_t, script_slot_data > screenmap;
111 38 std::map<int32_t, script_slot_data > itemspritemap;
112 38 std::map<int32_t, script_slot_data > comboscriptmap;
113 void free_newtilebuf();
114 bool combosread=false;
115 bool mapsread=false;
116 bool fixffcs=false;
117 bool fixpolsvoice=false;
118
119
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
120
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
121
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
122
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
123
124 char qstdat_string[2048] = { 0 };
125
126 static zinfo* load_tmp_zi = NULL;
127
128 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
129 const byte clavio[9]={97,109,111,110,103,117,115,0};
130
131 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
132 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
133
134 extern combo_alias combo_aliases[MAXCOMBOALIASES];
135 extern combo_pool combo_pools[MAXCOMBOPOOLS];
136 const char *qst_error[] =
137 {
138 "OK","File not found","Invalid quest file",
139 "Version not supported","Obsolete version",
140 "Missing new data" , /* but let it pass in ZQuest */
141 "Internal error occurred", "Invalid password",
142 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
143 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
144 };
145
146 //for legacy quests -DD
147 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
148 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
149 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
150 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
151 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
152 };
153
154 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
155
156
157 void delete_combo_aliases()
158 {
159 for(int32_t j(0); j<256; j++)
160 {
161 if(combo_aliases[j].combos != NULL)
162 {
163 delete[] combo_aliases[j].combos;
164 combo_aliases[j].combos=NULL;
165 }
166
167 if(combo_aliases[j].csets != NULL)
168 {
169 delete[] combo_aliases[j].csets;
170 combo_aliases[j].csets=NULL;
171 }
172 }
173
174 }
175
176 char *byte_conversion(int32_t number, int32_t format)
177 {
178 static char num_str[40];
179
180 if(format==-1) //auto
181 {
182 format=1; //bytes
183
184 if(number>1024)
185 {
186 format=2; //kilobytes
187 }
188
189 if(number>1024*1024)
190 {
191 format=3; //megabytes
192 }
193
194 if(number>1024*1024*1024)
195 {
196 format=4; //gigabytes (dude, what are you doing?)
197 }
198 }
199
200 switch(format)
201 {
202 case 1: //bytes
203 sprintf(num_str,"%db",number);
204 break;
205
206 case 2: //kilobytes
207 sprintf(num_str,"%.2fk",float(number)/1024);
208 break;
209
210 case 3: //megabytes
211 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
212 break;
213
214 case 4: //gigabytes
215 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
216 break;
217
218 default:
219 abort();
220 break;
221 }
222
223 return num_str;
224 }
225
226 532 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
227 {
228 static char num_str1[40];
229 static char num_str2[40];
230 static char num_str[80];
231
232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(format1==-1) //auto
233 {
234 532 format1=1; //bytes
235
236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(number1>1024)
237 {
238 532 format1=2; //kilobytes
239 532 }
240
241
2/2
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 152 times.
532 if(number1>1024*1024)
242 {
243 152 format1=3; //megabytes
244 152 }
245
246
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 if(number1>1024*1024*1024)
247 {
248 format1=4; //gigabytes (dude, what are you doing?)
249 }
250 532 }
251
252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(format2==-1) //auto
253 {
254 532 format2=1; //bytes
255
256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(number2>1024)
257 {
258 532 format2=2; //kilobytes
259 532 }
260
261
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 494 times.
532 if(number2>1024*1024)
262 {
263 494 format2=3; //megabytes
264 494 }
265
266
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 if(number2>1024*1024*1024)
267 {
268 format2=4; //gigabytes (dude, what are you doing?)
269 }
270 532 }
271
272
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 380 times.
✓ Branch 3 taken 152 times.
✗ Branch 4 not taken.
532 switch(format1)
273 {
274 case 1: //bytes
275 sprintf(num_str1,"%db",number1);
276 break;
277
278 case 2: //kilobytes
279 380 sprintf(num_str1,"%.2fk",float(number1)/1024);
280 380 break;
281
282 case 3: //megabytes
283 152 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
284 152 break;
285
286 case 4: //gigabytes
287 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
288 break;
289
290 default:
291 abort();
292 break;
293 }
294
295
2/5
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 494 times.
✗ Branch 4 not taken.
532 switch(format2)
296 {
297 case 1: //bytes
298 sprintf(num_str2,"%db",number2);
299 break;
300
301 case 2: //kilobytes
302 38 sprintf(num_str2,"%.2fk",float(number2)/1024);
303 38 break;
304
305 case 3: //megabytes
306 494 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
307 494 break;
308
309 case 4: //gigabytes
310 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
311 break;
312
313 default:
314 abort();
315 break;
316 }
317
318 532 sprintf(num_str, "%s/%s", num_str1, num_str2);
319 532 return num_str;
320 }
321
322 char *ordinal(int32_t num)
323 {
324 static const char *ending[4] = {"st","nd","rd","th"};
325 static char ord_str[8];
326
327 char *end;
328 int32_t t=(num%100)/10;
329 int32_t n=num%10;
330
331 if(n>=1 && n<4 && t!=1)
332 end = (char *)ending[n-1];
333 else
334 end = (char *)ending[3];
335
336 sprintf(ord_str,"%d%s",num%10000,end);
337 return ord_str;
338 }
339
340 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
341 {
342 int32_t ret;
343 *version=0;
344 *build=0;
345 byte temp_map_count=map_count;
346 byte temp_midi_flags[MIDIFLAGS_SIZE];
347 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
348
349 zquestheader tempheader;
350
351 if(!f)
352 {
353 return qe_invalid;
354 }
355
356 ret=readheader(f, &tempheader, true);
357
358 if(ret)
359 {
360 return ret;
361 }
362
363 map_count=temp_map_count;
364 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
365 *version=tempheader.zelda_version;
366 *build=tempheader.build;
367 return 0;
368 }
369
370
371 bool find_section(PACKFILE *f, int32_t section_id_requested)
372 {
373
374 if(!f)
375 {
376 return false;
377 }
378
379 int32_t section_id_read;
380 bool catchup=false;
381 word dummy;
382 byte tempbyte;
383 char tempbuf[65536];
384
385
386 switch(section_id_requested)
387 {
388 case ID_RULES:
389 case ID_STRINGS:
390 case ID_MISC:
391 case ID_TILES:
392 case ID_COMBOS:
393 case ID_CSETS:
394 case ID_MAPS:
395 case ID_DMAPS:
396 case ID_DOORS:
397 case ID_ITEMS:
398 case ID_WEAPONS:
399 case ID_COLORS:
400 case ID_ICONS:
401 case ID_INITDATA:
402 case ID_GUYS:
403 case ID_MIDIS:
404 case ID_CHEATS:
405 break;
406
407 default:
408 al_trace("Bad section requested!\n");
409 return false;
410 break;
411 }
412
413 dword section_size;
414
415 //section id
416 if(!p_mgetl(&section_id_read,f,true))
417 {
418 return false;
419 }
420
421 while(!pack_feof(f))
422 {
423 switch(section_id_read)
424 {
425 case ID_RULES:
426 case ID_STRINGS:
427 case ID_MISC:
428 case ID_TILES:
429 case ID_COMBOS:
430 case ID_CSETS:
431 case ID_MAPS:
432 case ID_DMAPS:
433 case ID_DOORS:
434 case ID_ITEMS:
435 case ID_WEAPONS:
436 case ID_COLORS:
437 case ID_ICONS:
438 case ID_INITDATA:
439 case ID_GUYS:
440 case ID_MIDIS:
441 case ID_CHEATS:
442 catchup=false;
443 break;
444
445 default:
446 break;
447 }
448
449
450 while(catchup)
451 {
452 //section id
453 section_id_read=(section_id_read<<8);
454
455 if(!p_getc(&tempbyte,f,true))
456 {
457 return false;
458 }
459
460 section_id_read+=tempbyte;
461 }
462
463 if(section_id_read==section_id_requested)
464 {
465 return true;
466 }
467 else
468 {
469 //section version info
470 if(!p_igetw(&dummy,f,true))
471 {
472 return false;
473 }
474
475 if(!p_igetw(&dummy,f,true))
476 {
477 return false;
478 }
479
480 //section size
481 if(!p_igetl(&section_size,f,true))
482 {
483 return false;
484 }
485
486 //pack_fseek(f, section_size);
487 while(section_size>65535)
488 {
489 pfread(tempbuf,65535,f,true);
490 tempbuf[65535]=0;
491 section_size-=65535;
492 }
493
494 if(section_size>0)
495 {
496 pfread(tempbuf,section_size,f,true);
497 tempbuf[section_size]=0;
498 }
499 }
500
501 //section id
502 if(!p_mgetl(&section_id_read,f,true))
503 {
504 return false;
505 }
506 }
507
508 return false;
509 }
510
511
512
513
514
515 bool valid_zqt(PACKFILE *f)
516 {
517
518 //word tiles_used;
519 //word combos_used;
520 //open the file
521 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
522 if(!f)
523 return false;
524
525 //for now, everything else is valid
526 return true;
527
528 /*int16_t version;
529 byte build;
530
531 //read the version and make sure it worked
532 if(!p_igetw(&version,f,true))
533 {
534 goto error;
535 }
536
537 //read the build and make sure it worked
538 if(!p_getc(&build,f,true))
539 goto error;
540
541 //read the tile info and make sure it worked
542 if(!p_igetw(&tiles_used,f,true))
543 {
544 goto error;
545 }
546
547 for (int32_t i=0; i<tiles_used; i++)
548 {
549 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
550 {
551 goto error;
552 }
553 }
554
555 //read the combo info and make sure it worked
556 if(!p_igetw(&combos_used,f,true))
557 {
558 goto error;
559 }
560 for (int32_t i=0; i<combos_used; i++)
561 {
562 if(!pfread(trashbuf,sizeof(newcombo),f,true))
563 {
564 goto error;
565 }
566 }
567
568 //read the palette info and make sure it worked
569 for (int32_t i=0; i<48; i++)
570 {
571 if(!pfread(trashbuf,newpdTOTAL,f,true))
572 {
573 goto error;
574 }
575 }
576 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
577 {
578 goto error;
579 }
580 for (int32_t i=0; i<MAXLEVELS; i++)
581 {
582 if(!pfread(trashbuf,PALNAMESIZE,f,true))
583 {
584 goto error;
585 }
586 }
587
588 //read the sprite info and make sure it worked
589 for (int32_t i=0; i<MAXITEMS; i++)
590 {
591 if(!pfread(trashbuf,sizeof(itemdata),f,true))
592 {
593 goto error;
594 }
595 }
596
597 for (int32_t i=0; i<MAXWPNS; i++)
598 {
599 if(!pfread(trashbuf,sizeof(wpndata),f,true))
600 {
601 goto error;
602 }
603 }
604
605 //read the triforce pieces info and make sure it worked
606 for (int32_t i=0; i<8; ++i)
607 {
608 if(!p_getc(&trashbuf,f,true))
609 {
610 goto error;
611 }
612 }
613
614
615
616 //read the game icons info and make sure it worked
617 for (int32_t i=0; i<4; ++i)
618 {
619 if(!p_igetw(&trashbuf,f,true))
620 {
621 goto error;
622 }
623 }
624
625 //read the misc colors info and map styles info and make sure it worked
626 if(!pfread(trashbuf,sizeof(zcolors),f,true))
627 {
628 goto error;
629 }
630
631 //read the template screens and make sure it worked
632 byte num_maps;
633 if(!p_getc(&num_maps,f,true))
634 {
635 goto error;
636 }
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f,true))
640 {
641 goto error;
642 }
643 }
644 if (num_maps>1) //dungeon templates
645 {
646 for (int32_t i=0; i<TEMPLATES; i++)
647 {
648 if(!pfread(trashbuf,sizeof(mapscr),f,true))
649 {
650 goto error;
651 }
652 }
653 }
654
655 //yay! it worked! close the file and say everything was ok.
656 pack_fclose(f);
657 return true;
658
659 error:
660 pack_fclose(f);
661 return false;*/
662 }
663
664 bool valid_zqt(const char *filename)
665 {
666 PACKFILE *f=NULL;
667 bool isvalid;
668 int32_t error;
669 f=open_quest_file(&error, filename, false);
670
671 if(!f)
672 {
673 // setPackfilePassword(NULL);
674 return false;
675 }
676
677 isvalid=valid_zqt(f);
678
679 clear_quest_tmpfile();
680 pack_fclose(f);
681
682 // setPackfilePassword(NULL);
683 return isvalid;
684 }
685
686 38 static std::string tmp_file_name;
687 228 void clear_quest_tmpfile()
688 {
689
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(tmp_file_name.size())
690 {
691 if(exists(tmp_file_name.c_str()))
692 delete_file(tmp_file_name.c_str());
693 tmp_file_name.clear();
694 }
695 228 }
696 /*
697 .qst file history
698
699 .qst files have always been compressed using allegro's packfiles.
700
701 At some point, an encoding layer was added. The two layers look like this:
702
703 1) The top layer is from us. See decode_file_007.
704 [0-24] Preamble "Zelda Classic Quest File"
705 [25-28] Initial decoding seed value.
706 [29-X] Allegro-encoded payload (AKA "packed" file)
707 [last 4] Checksum
708
709 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
710 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
711 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
712 The oldest quests skip the password part.
713
714 Simply, the job of this function is to peel away the top layer.
715
716 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
717 in opening and saving files. There is no version field, so they decryption key is
718 found via trial-by-error (very slow!)
719
720 There are other file types of interest:
721 - .zqt: quest template files, skips top-layer encryption pass
722 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
723 - .qu?: same as above. automated backup files
724 - .qb?: same as above. automated backup files
725 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
726
727 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
728 files are now "slh!.AG ZC Enhanced Quest File".
729 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
730 */
731 114 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
732 {
733
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if (show_progress)
734 {
735 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
736 }
737
738 #ifdef __EMSCRIPTEN__
739 if (em_is_lazy_file(filename))
740 {
741 em_fetch_file(filename);
742 }
743 #endif
744 114 clear_quest_tmpfile();
745 // Note: although this is primarily for loading .qst files, it can also handle all of the
746 // file types mentioned in the comment above. No need to be told if the file being loaded
747 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
748 114 bool top_layer_compressed = false;
749 114 bool compressed = false;
750 114 bool encrypted = false;
751
752 // Input files may or may not include a top layer, which may or may not be compressed.
753 // Additionally, the bottom layer may or may not be compressed, and may or may not be encoded
754 // with an allegro packfile password (longtan).
755 // We peek into this file to read the header - we'll either see the top layer's header (ENC_STR)
756 // or the bottom layer's header (QH_IDSTR or QH_NEWIDSTR).
757 // Newly saved .qst files enjoy a fast path here, where there is no top layer at all.
758
759 114 bool id_came_from_compressed_file = false;
760 114 const char* packfile_password = "";
761 char id[32];
762 114 id[0] = id[31] = '\0';
763 114 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, "");
764
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 3 times.
114 if (!pf)
765 3 pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password = datapwd);
766
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 3 times.
114 if (pf)
767 {
768 111 id_came_from_compressed_file = true;
769
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if (!pack_fread(id, sizeof(id)-1, pf))
770 {
771 pack_fclose(pf);
772 Z_message("Unable to read header string\n");
773 return nullptr;
774 }
775 111 pack_fclose(pf);
776 111 }
777 else
778 {
779 3 FILE* f = fopen(filename, "rb");
780
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!f)
781 {
782 *open_error=qe_notfound;
783 return nullptr;
784 }
785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!fread(id, sizeof(char), sizeof(id)-1, f))
786 {
787 fclose(f);
788 Z_message("Unable to read header string\n");
789 return nullptr;
790 }
791 3 fclose(f);
792 }
793
794
4/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 3 times.
114 if (strstr(id, QH_NEWIDSTR) || strstr(id, QH_IDSTR))
795 {
796 // The given file is already just the bottom layer - nothing more to do.
797 // There's no way to rewind a packfile, so just open it again.
798
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if (id_came_from_compressed_file)
799 {
800 111 return pack_fopen_password(filename, F_READ_PACKED, packfile_password);
801 }
802 else
803 {
804 return pack_fopen_password(filename, F_READ, "");
805 }
806 }
807
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if (strstr(id, ENC_STR))
808 {
809 3 top_layer_compressed = id_came_from_compressed_file;
810 3 compressed = true;
811 3 encrypted = true;
812 3 }
813 else if (id_came_from_compressed_file && strstr(id, "slh!\xff"))
814 {
815 // We must be reading the compressed contents of an allegro dataobject file. ex: `classic_qst.dat#NESQST_NEW_QST`.
816 // Let's extract the content and re-open as a separate file, so allegro will uncompress correctly.
817
818 char tmpfilename[L_tmpnam];
819 std::tmpnam(tmpfilename);
820 FILE* tf = fopen(tmpfilename, "wb");
821 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password);
822
823 int c;
824 while ((c = pack_getc(pf)) != EOF)
825 {
826 fputc(c, tf);
827 }
828 fclose(tf);
829 pack_fclose(pf);
830
831 tmp_file_name = tmpfilename; //store so it can be cleaned up later
832
833 // not good: temp file storage leak. Callers don't know to delete temp files anymore.
834 // We should put qsu in the dat file, or use a separate .qst file for new qst.
835 return pack_fopen_password(tmpfilename, F_READ_PACKED, "");
836 }
837 else
838 {
839 // Unexpected, this is going to fail some header check later.
840 }
841
842 // Everything below here is legacy code - recently saved quest files will have
843 // returned by now.
844
845 char tmpfilename[L_tmpnam];
846 3 temp_name(tmpfilename);
847 char percent_done[30];
848 3 int32_t current_method=0;
849
850 PACKFILE *f;
851 3 const char *passwd= encrypted ? datapwd : "";
852
853 // oldquest flag is set when an unencrypted qst file is suspected.
854 3 bool oldquest = false;
855 int32_t ret;
856
857
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, "default.qst")!=0)
858 {
859 3 box_out(filename);
860 3 }
861 else
862 {
863 box_out("new quest"); // Or whatever
864 }
865 3 box_out("...");
866 3 box_eol();
867 3 box_eol();
868
869
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
870 {
871 3 box_out("Decrypting...");
872 3 box_save_x();
873 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
874
875
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
876 {
877 switch(ret)
878 {
879 case 1:
880 box_out("error.");
881 box_eol();
882 box_end(true);
883 *open_error=qe_notfound;
884 return NULL;
885
886 case 2:
887 box_out("error.");
888 box_eol();
889 box_end(true);
890 *open_error=qe_internal;
891 return NULL;
892 // be sure not to delete tmpfilename now...
893 }
894
895 if(ret==5) //old encryption?
896 {
897 current_method++;
898 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
899 box_out(percent_done);
900 box_load_x();
901 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
902 }
903
904 if(ret==5) //old encryption?
905 {
906 current_method++;
907 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
908 box_out(percent_done);
909 box_load_x();
910 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
911 }
912
913 if(ret==5) //old encryption?
914 {
915 current_method++;
916 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
917 box_out(percent_done);
918 box_load_x();
919 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
920 }
921
922 if(ret==5) //old encryption?
923 {
924 current_method++;
925 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
926 box_out(percent_done);
927 box_load_x();
928 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
929 }
930
931 if(ret)
932 {
933 oldquest = true;
934 passwd="";
935 }
936 }
937
938 3 box_out("okay.");
939 3 box_eol();
940 3 }
941 else
942 {
943 oldquest = true;
944 }
945
946 3 box_out("Opening...");
947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
948
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
949 {
950 if((compressed==1)&&(errno==EDOM))
951 {
952 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
953 }
954
955 if(!f)
956 {
957 if(!oldquest)
958 {
959 delete_file(tmpfilename);
960 }
961 box_out("error.");
962 box_eol();
963 box_end(true);
964 *open_error=qe_invalid;
965 return NULL;
966 }
967 }
968
969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
970 {
971 3 delete_file(tmpfilename);
972 3 }
973
974 3 box_out("okay.");
975 3 box_eol();
976
977 3 return f;
978 114 }
979
980 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
981 {
982 char *filename;
983 PACKFILE *f=NULL;
984 int32_t open_error=0;
985
986 strcpy(qstdat_string, "modules/classic/default.qst");
987 if(Header->templatepath[0]==0)
988 {
989 filename=(char *)malloc(2048);
990 strcpy(filename, qstdat_string);
991 }
992 else
993 {
994 // TODO: should be safe to remove this, no one seems to use custom quest templates.
995 filename=Header->templatepath;
996 }
997
998 f=open_quest_file(&open_error, filename, false);
999
1000 if(Header->templatepath[0]==0)
1001 {
1002 free(filename);
1003 }
1004
1005 if(!f)
1006 {
1007 return NULL;
1008 }
1009
1010 if(validate)
1011 {
1012 if(!valid_zqt(f))
1013 {
1014 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1015 pack_fclose(f);
1016 clear_quest_tmpfile();
1017 return NULL;
1018 }
1019 }
1020
1021 return f;
1022 }
1023
1024 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
1025 {
1026 // We absolutely do not support loading from a template file to initialize data outside the editor.
1027 // TODO: move this code into zq/
1028 if (get_app_id() != App::zquest) return false;
1029
1030 combosread=false;
1031 mapsread=false;
1032 fixffcs=false;
1033
1034 switch(section_id)
1035 {
1036 case ID_RULES:
1037 case ID_STRINGS:
1038 case ID_MISC:
1039 case ID_TILES:
1040 case ID_COMBOS:
1041 case ID_CSETS:
1042 case ID_MAPS:
1043 case ID_DMAPS:
1044 case ID_DOORS:
1045 case ID_ITEMS:
1046 case ID_WEAPONS:
1047 case ID_COLORS:
1048 case ID_ICONS:
1049 case ID_INITDATA:
1050 case ID_GUYS:
1051 case ID_MIDIS:
1052 case ID_CHEATS:
1053 case ID_ITEMDROPSETS:
1054 case ID_FAVORITES:
1055 break;
1056
1057 default:
1058 return false;
1059 break;
1060 }
1061
1062 int32_t ret;
1063 word version, build;
1064 PACKFILE *f=NULL;
1065
1066 char deletefilename[1024];
1067 deletefilename[0]=0;
1068
1069 //why is this here?
1070 /*
1071 if(colordata==NULL)
1072 return false;
1073 */
1074
1075 //setPackfilePassword(datapwd);
1076 f=open_quest_template(Header, deletefilename, validate);
1077
1078 if(!f) //no file, nothing to delete
1079 {
1080 // setPackfilePassword(NULL);
1081 return false;
1082 }
1083
1084 ret=get_version_and_build(f, &version, &build);
1085
1086 if(ret||(version==0))
1087 {
1088 pack_fclose(f);
1089 clear_quest_tmpfile();
1090
1091 if(deletefilename[0])
1092 {
1093 delete_file(deletefilename);
1094 }
1095
1096 // setPackfilePassword(NULL);
1097 return false;
1098 }
1099
1100 if(!find_section(f, section_id))
1101 {
1102 al_trace("Can't find section!\n");
1103 pack_fclose(f);
1104 clear_quest_tmpfile();
1105
1106 if(deletefilename[0])
1107 {
1108 delete_file(deletefilename);
1109 }
1110
1111 //setPackfilePassword(NULL);
1112 return false;
1113 }
1114
1115 switch(section_id)
1116 {
1117 case ID_RULES:
1118 //rules
1119 ret=readrules(f, Header, true);
1120 break;
1121
1122 case ID_STRINGS:
1123 //strings
1124 ret=readstrings(f, Header, true);
1125 break;
1126
1127 case ID_MISC:
1128 //misc data
1129 ret=readmisc(f, Header, Misc, true);
1130 break;
1131
1132 case ID_TILES:
1133 //tiles
1134 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
1135 break;
1136
1137 case ID_COMBOS:
1138 //combos
1139 clear_combos();
1140 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1141 combosread=true;
1142 break;
1143
1144 case ID_COMBOALIASES:
1145 //combos
1146 ret=readcomboaliases(f, Header, version, build, true);
1147 break;
1148
1149 case ID_CSETS:
1150 //color data
1151 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1152 break;
1153
1154 case ID_MAPS:
1155 //maps
1156 ret=readmaps(f, Header, true);
1157 mapsread=true;
1158 break;
1159
1160 case ID_DMAPS:
1161 //dmaps
1162 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1163 break;
1164
1165 case ID_DOORS:
1166 //door combo sets
1167 ret=readdoorcombosets(f, Header, true);
1168 break;
1169
1170 case ID_ITEMS:
1171 //items
1172 ret=readitems(f, version, build, true);
1173 break;
1174
1175 case ID_WEAPONS:
1176 //weapons
1177 ret=readweapons(f, Header, true);
1178 break;
1179
1180 case ID_COLORS:
1181 //misc. colors
1182 ret=readmisccolors(f, Header, Misc, true);
1183 break;
1184
1185 case ID_ICONS:
1186 //game icons
1187 ret=readgameicons(f, Header, Misc, true);
1188 break;
1189
1190 case ID_INITDATA:
1191 //initialization data
1192 ret=readinitdata(f, Header, true);
1193 break;
1194
1195 case ID_GUYS:
1196 //guys
1197 ret=readguys(f, Header, true);
1198 break;
1199
1200 case ID_MIDIS:
1201 //midis
1202 ret=readtunes(f, Header, tunes, true);
1203 break;
1204
1205 case ID_CHEATS:
1206 //cheat codes
1207 ret=readcheatcodes(f, Header, true);
1208 break;
1209
1210 case ID_ITEMDROPSETS:
1211 //item drop sets
1212 // Why is this one commented out?
1213 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1214 break;
1215
1216 case ID_FAVORITES:
1217 // favorite combos and aliases
1218 ret=readfavorites(f, version, build, true);
1219 break;
1220
1221 default:
1222 ret=-1;
1223 break;
1224 }
1225
1226 pack_fclose(f);
1227 clear_quest_tmpfile();
1228
1229 if(deletefilename[0])
1230 {
1231 delete_file(deletefilename);
1232 }
1233
1234 //setPackfilePassword(NULL);
1235 if(!ret)
1236 {
1237 return true;
1238 }
1239
1240 return false;
1241 }
1242
1243 bool init_tiles(bool validate, zquestheader *Header)
1244 {
1245 return init_section(Header, ID_TILES, NULL, NULL, validate);
1246 }
1247
1248 bool init_combos(bool validate, zquestheader *Header)
1249 {
1250 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1251 }
1252
1253 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1254 {
1255 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1256 }
1257
1258 114 void init_spritelists()
1259 {
1260
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
114 if(FFCore.quest_format[vZelda] < 0x255)
1261 {
1262 85 guys.setMax(255);
1263 85 items.setMax(255);
1264 85 Ewpns.setMax(255);
1265 85 Lwpns.setMax(255);
1266 85 Sitems.setMax(255);
1267 85 chainlinks.setMax(255);
1268 85 decorations.setMax(255);
1269 85 particles.setMax(255);
1270 85 }
1271 else
1272 {
1273 29 guys.setMax(255);
1274 29 items.setMax(255);
1275 29 Ewpns.setMax(255);
1276 29 Lwpns.setMax(255);
1277 29 Sitems.setMax(255);
1278 29 chainlinks.setMax(255);
1279 29 decorations.setMax(255);
1280 29 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1281 }
1282 114 }
1283
1284 38 bool reset_items(bool validate, zquestheader *Header)
1285 {
1286 38 bool ret = true;
1287
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (get_app_id() == App::zquest)
1288 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1289
1290
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 9728 times.
9766 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1291
1292 38 return ret;
1293 }
1294
1295 bool reset_guys()
1296 {
1297 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1298 init_guys(V_GUYS);
1299 return true;
1300 }
1301
1302 bool reset_wpns(bool validate, zquestheader *Header)
1303 {
1304 bool ret = true;
1305 if (get_app_id() == App::zquest)
1306 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1307
1308 for(int32_t i=0; i<WPNCNT; i++)
1309 reset_weaponname(i);
1310
1311 return ret;
1312 }
1313
1314 bool reset_mapstyles(bool validate, miscQdata *Misc)
1315 {
1316 Misc->colors.blueframe_tile = 20044;
1317 Misc->colors.blueframe_cset = 0;
1318 Misc->colors.triforce_tile = 23461;
1319 Misc->colors.triforce_cset = 1;
1320 Misc->colors.triframe_tile = 18752;
1321 Misc->colors.triframe_cset = 1;
1322 Misc->colors.overworld_map_tile = 16990;
1323 Misc->colors.overworld_map_cset = 2;
1324 Misc->colors.HCpieces_tile = 21160;
1325 Misc->colors.HCpieces_cset = 8;
1326 Misc->colors.dungeon_map_tile = 19651;
1327 Misc->colors.dungeon_map_cset = 8;
1328 return true;
1329 }
1330
1331 38 int32_t get_qst_buffers()
1332 {
1333 38 memrequested+=(sizeof(mapscr)*MAPSCRS);
1334 38 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1335 38 TheMaps.resize(MAPSCRS);
1336
1337
2/2
✓ Branch 0 taken 5168 times.
✓ Branch 1 taken 38 times.
5206 for(int32_t i(0); i<MAPSCRS; i++)
1338 5168 TheMaps[i].zero_memory();
1339
1340 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1341 38 Z_message("OK\n"); // Allocating map buffer...
1342
1343 38 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1344 38 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1345
1346
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1347 return 0;
1348
1349 38 Z_message("OK\n");
1350
1351 // Allocating space for all 65535 strings uses up 10.62MB...
1352 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1353 // (Shoelace's "Hero of Dreams" uses 1415.)
1354 // So let's be a bit generous and allow 4096 initially.
1355 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1356 // I tested it and it worked without flaw on 6/6/11. - L.
1357 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1358 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1359 // See https://discord.com/channels/876899628556091432/992984989073416242
1360 38 msg_strings_size = 8192;
1361 38 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1362 38 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1363
1364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 MsgStrings = new MsgStr[msg_strings_size];
1365
1366 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1367
2/2
✓ Branch 0 taken 311296 times.
✓ Branch 1 taken 38 times.
311334 for(auto q = 0; q < msg_strings_size; ++q)
1368 {
1369 311296 MsgStrings[q].clear();
1370 311296 }
1371 38 Z_message("OK\n"); // Allocating string buffer...
1372
1373 38 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1374 38 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1375
1376
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1377 return 0;
1378
1379 38 Z_message("OK\n"); // Allocating door combo buffer...
1380
1381 38 memrequested+=(sizeof(dmap)*MAXDMAPS);
1382 38 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1383
1384
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1385 return 0;
1386
1387 38 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1388 38 Z_message("OK\n"); // Allocating dmap buffer...
1389
1390 38 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1391 38 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1392
1393 38 combobuf.clear();
1394 38 combobuf.resize(MAXCOMBOS);
1395 38 Z_message("OK\n"); // Allocating combo buffer...
1396
1397 38 memrequested+=(psTOTAL255);
1398 38 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1399
1400
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1401 return 0;
1402
1403 38 Z_message("OK\n"); // Allocating color data buffer...
1404
1405 38 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1406 38 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1407
1408 38 free_newtilebuf();
1409
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1410 return 0;
1411
1412 38 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1413 //Z_message("Performed memset on tiles\n");
1414 38 clear_tiles(newtilebuf);
1415 //Z_message("Performed clear_tiles()\n");
1416 38 Z_message("OK\n"); // Allocating tile buffer...
1417
1418
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(is_zquest())
1419 {
1420 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1421 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1422
1423 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1424 return 0;
1425
1426 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1427 clear_tiles(grabtilebuf);
1428 Z_message("OK\n"); // Allocating tile grab buffer...
1429 }
1430
1431 38 memrequested+=(100000);
1432 38 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1433
1434
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((trashbuf=(byte*)malloc(100000))==NULL)
1435 return 0;
1436
1437 38 Z_message("OK\n"); // Allocating trash buffer...
1438
1439 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1440 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1441 // fixed by ensuring there's actually itemdata there.
1442 // If you change this, be sure to update del_qst_buffers, too.
1443
1444 38 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1445 38 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1446
1447
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1448 return 0;
1449
1450 38 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1451 38 itemsbuf++;
1452 38 Z_message("OK\n"); // Allocating item buffer...
1453
1454 38 memrequested+=(sizeof(wpndata)*MAXWPNS);
1455 38 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1456
1457
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1458 return 0;
1459
1460 38 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1461 38 Z_message("OK\n"); // Allocating weapon buffer...
1462
1463 38 memrequested+=(sizeof(guydata)*MAXGUYS);
1464 38 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1465
1466
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1467 return 0;
1468
1469 38 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1470 38 Z_message("OK\n"); // Allocating guy buffer...
1471
1472 38 memrequested+=(sizeof(comboclass)*cMAX);
1473 38 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1474
1475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1476 return 0;
1477
1478 38 Z_message("OK\n"); // Allocating combo class buffer...
1479
1480 38 return 1;
1481 38 }
1482
1483
1484 38 void free_newtilebuf()
1485 {
1486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(newtilebuf)
1487 {
1488 for(int32_t i=0; i<NEWMAXTILES; i++)
1489 if(newtilebuf[i].data)
1490 free(newtilebuf[i].data);
1491
1492 free(newtilebuf);
1493 newtilebuf = 0;
1494 }
1495 38 }
1496
1497 void free_grabtilebuf()
1498 {
1499 if(is_zquest())
1500 {
1501 if(grabtilebuf)
1502 {
1503 for(int32_t i=0; i<NEWMAXTILES; i++)
1504 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1505
1506 free(grabtilebuf);
1507 grabtilebuf = 0;
1508 }
1509 }
1510 }
1511
1512 void del_qst_buffers()
1513 {
1514 al_trace("Cleaning maps. \n");
1515
1516 if(ZCMaps) free(ZCMaps);
1517
1518 if(MsgStrings) delete[] MsgStrings;
1519
1520 if(DoorComboSets) free(DoorComboSets);
1521
1522 if(DMaps) free(DMaps);
1523
1524 combobuf.clear();
1525
1526 if(colordata) free(colordata);
1527
1528 al_trace("Cleaning tile buffers. \n");
1529 free_newtilebuf();
1530 free_grabtilebuf();
1531
1532 al_trace("Cleaning misc. \n");
1533
1534 if(trashbuf) free(trashbuf);
1535
1536 // See get_qst_buffers
1537 if(itemsbuf)
1538 {
1539 itemsbuf--;
1540 free(itemsbuf);
1541 }
1542
1543 if(wpnsbuf) free(wpnsbuf);
1544
1545 if(guysbuf) free(guysbuf);
1546
1547 if(combo_class_buf) free(combo_class_buf);
1548 }
1549
1550 4 bool init_palnames()
1551 {
1552 // if(palnames==NULL)
1553 // return false;
1554
1555
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1556 {
1557
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1558 {
1559 case 0:
1560 4 sprintf(palnames[x],"Overworld");
1561 4 break;
1562
1563 case 10:
1564 4 sprintf(palnames[x],"Caves");
1565 4 break;
1566
1567 case 11:
1568 4 sprintf(palnames[x],"Passageways");
1569 4 break;
1570
1571 default:
1572 2036 sprintf(palnames[x],"%c",0);
1573 2036 break;
1574 }
1575 2048 }
1576
1577 4 return true;
1578 }
1579
1580 21367 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1581 {
1582 void *p;
1583
1584
1/2
✓ Branch 0 taken 21367 times.
✗ Branch 1 not taken.
21367 p = _AL_MALLOC(MAX(size, alloc_size));
1585
1586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21367 times.
21367 if(!p)
1587 {
1588 return NULL;
1589 }
1590
1591
1/2
✓ Branch 0 taken 21367 times.
✗ Branch 1 not taken.
21367 if(!pfread(p,size,f,keepdata))
1592 {
1593 _AL_FREE(p);
1594 return NULL;
1595 }
1596
1597
1/2
✓ Branch 0 taken 21367 times.
✗ Branch 1 not taken.
21367 if(pack_ferror(f))
1598 {
1599 _AL_FREE(p);
1600 return NULL;
1601 }
1602
1603 21367 return p;
1604 21367 }
1605
1606 /* read_midi:
1607 * Reads MIDI data from a datafile (this is not the same thing as the
1608 * standard midi file format).
1609 */
1610
1611 1875 static MIDI *read_midi(PACKFILE *f, bool)
1612 {
1613 MIDI *m;
1614 int32_t c;
1615 1875 int16_t divisions=0;
1616 1875 int32_t len=0;
1617
1618 1875 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1619
1620
1/2
✓ Branch 0 taken 1875 times.
✗ Branch 1 not taken.
1875 if(!m)
1621 {
1622 return NULL;
1623 }
1624
1625
2/2
✓ Branch 0 taken 60000 times.
✓ Branch 1 taken 1875 times.
61875 for(c=0; c<MIDI_TRACKS; c++)
1626 {
1627 60000 m->track[c].len = 0;
1628 60000 m->track[c].data = NULL;
1629 60000 }
1630
1631 1875 p_mgetw(&divisions,f,true);
1632 1875 m->divisions=divisions;
1633
1634
2/2
✓ Branch 0 taken 60000 times.
✓ Branch 1 taken 1875 times.
61875 for(c=0; c<MIDI_TRACKS; c++)
1635 {
1636 60000 p_mgetl(&len,f,true);
1637 60000 m->track[c].len=len;
1638
1639
2/2
✓ Branch 0 taken 38633 times.
✓ Branch 1 taken 21367 times.
60000 if(m->track[c].len > 0)
1640 {
1641 21367 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1642
1643
1/2
✓ Branch 0 taken 21367 times.
✗ Branch 1 not taken.
21367 if(!m->track[c].data)
1644 {
1645 destroy_midi(m);
1646 return NULL;
1647 }
1648 21367 }
1649 60000 }
1650
1651 LOCK_DATA(m, sizeof(MIDI));
1652
1653
2/2
✓ Branch 0 taken 60000 times.
✓ Branch 1 taken 1875 times.
61875 for(c=0; c<MIDI_TRACKS; c++)
1654 {
1655
2/2
✓ Branch 0 taken 21367 times.
✓ Branch 1 taken 38633 times.
60000 if(m->track[c].data)
1656 {
1657 LOCK_DATA(m->track[c].data, m->track[c].len);
1658 21367 }
1659 60000 }
1660
1661 1875 return m;
1662 1875 }
1663
1664 void clear_combo(int32_t i)
1665 {
1666 combobuf[i].clear();
1667 }
1668
1669 void clear_combos()
1670 {
1671 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1672 clear_combo(tmpcounter);
1673 }
1674
1675 void pack_combos()
1676 {
1677 int32_t di = 0;
1678
1679 for(int32_t si=0; si<1024; si+=2)
1680 combobuf[di++] = combobuf[si];
1681
1682 for(; di<1024; di++)
1683 clear_combo(di);
1684 }
1685
1686 114 void reset_tunes(zctune *tune)
1687 {
1688
2/2
✓ Branch 0 taken 28728 times.
✓ Branch 1 taken 114 times.
28842 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1689 {
1690 28728 tune[i].reset();
1691 28728 }
1692 114 }
1693
1694
1695 /*void reset_midi(zcmidi_ *m)
1696 {
1697 m->title[0]=0;
1698 m->loop=1;
1699 m->volume=144;
1700 m->start=0;
1701 m->loop_start=-1;
1702 m->loop_end=-1;
1703 if(m->midi)
1704 {
1705 destroy_midi(m->midi);
1706 }
1707 m->midi=NULL;
1708 }
1709
1710
1711 void reset_midis(zcmidi_ *m)
1712 {
1713 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1714 {
1715 reset_midi(m+i);
1716 }
1717 }
1718 */
1719
1720 void reset_scr(int32_t scr)
1721 {
1722 /*
1723 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1724 for(unsigned i=0; i<sizeof(mapscr); i++)
1725 *(di++) = 0;
1726 TheMaps[scr].valid=mVERSION;
1727 */
1728
1729 TheMaps[scr].zero_memory();
1730 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1731
1732 for(int32_t i=0; i<6; i++)
1733 {
1734 //these will be uncommented later
1735 //TheMaps[scr].layerxsize[i]=16;
1736 //TheMaps[scr].layerysize[i]=11;
1737 TheMaps[scr].layeropacity[i]=255;
1738 }
1739
1740 TheMaps[scr].valid=mVERSION;
1741
1742 }
1743
1744 /* For reference:
1745
1746 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1747 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1748 */
1749
1750 3582 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1751 {
1752
2/2
✓ Branch 0 taken 16494 times.
✓ Branch 1 taken 1614 times.
18108 for(int32_t i=0; i<9; i++)
1753 {
1754
2/2
✓ Branch 0 taken 89124 times.
✓ Branch 1 taken 14526 times.
103650 for(int32_t j=0; j<6; j++)
1755 {
1756
2/2
✓ Branch 0 taken 29052 times.
✓ Branch 1 taken 60072 times.
89124 if(j<4)
1757 {
1758
2/2
✓ Branch 0 taken 58104 times.
✓ Branch 1 taken 1968 times.
60072 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1759 {
1760 1968 return false;
1761 }
1762
1763
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1764 {
1765 return false;
1766 }
1767
1768
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1769 {
1770 return false;
1771 }
1772
1773
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1774 {
1775 return false;
1776 }
1777 58104 }
1778
1779
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1780 {
1781 return false;
1782 }
1783
1784
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1785 {
1786 return false;
1787 }
1788
1789
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1790 {
1791 return false;
1792 }
1793
1794
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1795 {
1796 return false;
1797 }
1798 87156 }
1799
1800
2/2
✓ Branch 0 taken 11298 times.
✓ Branch 1 taken 3228 times.
14526 if(i<2)
1801 {
1802
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.flags[i]!=b.flags[i])
1803 {
1804 return false;
1805 }
1806
1807
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1808 {
1809 return false;
1810 }
1811
1812
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1813 {
1814 return false;
1815 }
1816
1817
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1818 {
1819 return false;
1820 }
1821
1822
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1823 {
1824 return false;
1825 }
1826 3228 }
1827
1828
2/2
✓ Branch 0 taken 9684 times.
✓ Branch 1 taken 4842 times.
14526 if(i<3)
1829 {
1830
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1831 {
1832 return false;
1833 }
1834
1835
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1836 {
1837 return false;
1838 }
1839
1840
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1841 {
1842 return false;
1843 }
1844
1845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4842 times.
4842 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1846 {
1847 return false;
1848 }
1849 4842 }
1850
1851
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1852 {
1853 return false;
1854 }
1855
1856
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1857 {
1858 return false;
1859 }
1860 14526 }
1861
1862 1614 return true;
1863 3582 }
1864
1865 int32_t doortranslations_u[9][4]=
1866 {
1867 {37,38,53,54},
1868 {37,38,39,40},
1869 {37,38,55,56},
1870 {37,38,39,40},
1871 {37,38,53,54},
1872 {37,38,53,54},
1873 {37,38,53,54},
1874 {7,8,23,24},
1875 {7,8,41,42}
1876 };
1877
1878 int32_t doortranslations_d[9][4]=
1879 {
1880 {117,118,133,134},
1881 {135,136,133,134},
1882 {119,120,133,134},
1883 {135,136,133,134},
1884 {117,118,133,134},
1885 {117,118,133,134},
1886 {117,118,133,134},
1887 {151,152,167,168},
1888 {137,138,167,168},
1889 };
1890
1891 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1892 int32_t doortranslations_l[9][6]=
1893 {
1894 {66,67,82,83,98,99},
1895 {66,68,82,84,98,100},
1896 {66,69,82,85,98,101},
1897 {66,68,82,84,98,100},
1898 {66,67,82,83,98,99},
1899 {66,67,82,83,98,99},
1900 {66,67,82,83,98,99},
1901 {64,65,80,81,96,97},
1902 {64,65,80,114,96,97},
1903 };
1904
1905 int32_t doortranslations_r[9][6]=
1906 {
1907
1908 {76,77,92,93,108,109},
1909 {75,77,91,93,107,109},
1910 {74,77,90,93,106,109},
1911 {75,77,91,93,107,109},
1912 {76,77,92,93,108,109},
1913 {76,77,92,93,108,109},
1914 {76,77,92,93,108,109},
1915 {78,79,94,95,110,111},
1916 {78,79,125,95,110,111},
1917 };
1918
1919 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1920 {
1921 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1922 }
1923
1924 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1925 {
1926 //these are here to bypass compiler warnings about unused arguments
1927 308180 map=map;
1928 308180 scr=scr;
1929 308180 pos=pos;
1930
1931 //what does this function do?
1932 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1933 308180 return 2;
1934 }
1935
1936 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1937 {
1938
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1939 {
1940 5450 return 0;
1941 }
1942
1943 DoorComboSet tempdcs;
1944 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1945
1946 //up
1947
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1948 {
1949
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1950 {
1951 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1952 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1953 58392 }
1954 14598 }
1955
1956 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1957 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1958 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1959 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1960 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1961 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1962
1963 //down
1964
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1965 {
1966
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1967 {
1968 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1969 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1970 58392 }
1971 14598 }
1972
1973 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1974
1975 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1976 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1977 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1978 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1979 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1980
1981 //left
1982 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1983
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1984 {
1985
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1986 {
1987 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1988 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1989 87588 }
1990 14598 }
1991
1992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1993 {
1994 if((j!=2)&&(j!=3))
1995 {
1996 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1997 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1998 }
1999 }
2000
2001 1622 tempdcs.bombdoorcombo_l[0]=0;
2002 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
2003 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
2004 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
2005 1622 tempdcs.bombdoorcombo_l[2]=0;
2006 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
2007 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
2008 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
2009
2010 //right
2011
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
2012 {
2013
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
2014 {
2015 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
2016 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
2017 87588 }
2018 14598 }
2019
2020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
2021 {
2022 if((j!=2)&&(j!=3))
2023 {
2024 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
2025 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
2026 }
2027 }
2028
2029 1622 tempdcs.bombdoorcombo_r[0]=0;
2030 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
2031 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
2032 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
2033 1622 tempdcs.bombdoorcombo_r[2]=0;
2034 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
2035 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
2036 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
2037
2038 int32_t k;
2039
2040
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3582 times.
3590 for(k=0; k<door_combo_set_count; k++)
2041 {
2042
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 1968 times.
3582 if(DoorComboSets[k]==tempdcs)
2043 {
2044 1614 break;
2045 }
2046 1968 }
2047
2048
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 8 times.
1622 if(k==door_combo_set_count)
2049 {
2050 8 DoorComboSets[k]=tempdcs;
2051 8 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
2052 8 ++door_combo_set_count;
2053 8 }
2054
2055 1622 return k;
2056 /*
2057 doorcombo_u[9][4];
2058 doorcset_u[9][4];
2059 doorcombo_d[9][4];
2060 doorcset_d[9][4];
2061 doorcombo_l[9][6];
2062 doorcset_l[9][6];
2063 doorcombo_r[9][6];
2064 doorcset_r[9][6];
2065 bombdoorcombo_u[2];
2066 bombdoorcset_u[2];
2067 bombdoorcombo_d[2];
2068 bombdoorcset_d[2];
2069 bombdoorcombo_l[3];
2070 bombdoorcset_l[3];
2071 bombdoorcombo_r[3];
2072 bombdoorcset_r[3];
2073 walkthroughcombo[4];
2074 walkthroughcset[4];
2075 */
2076 7072 }
2077
2078 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
2079 {
2080 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
2081 }
2082
2083 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
2084 {
2085
2086 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
2087 }
2088
2089 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
2090 {
2091 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
2092 }
2093
2094
2095 9 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
2096 {
2097 char temp_pwd[30];
2098 9 memset(temp_pwd,0,30);
2099
2100
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(pwdkey!=0)
2101 {
2102 9 memcpy(temp_pwd,encrypted_pwd,30);
2103 9 temp_pwd[29]=0;
2104
2105
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 9 times.
279 for(int32_t i=0; i<30; i++)
2106 {
2107 270 temp_pwd[i] -= pwdkey;
2108 270 int32_t t=pwdkey>>15;
2109 270 pwdkey = (pwdkey<<1)+t;
2110 270 }
2111 9 }
2112
2113 9 memcpy(pwd,temp_pwd,30);
2114 9 }
2115
2116
2117 85 bool devpwd()
2118 {
2119 #ifdef _DEBUG
2120 return true;
2121 #endif
2122 85 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
2123 }
2124 bool check_questpwd(zquestheader *Header, char *pwd)
2125 {
2126 #if DEVLEVEL > 3
2127 return true;
2128 #endif
2129
2130 if (devpwd()) return true;
2131 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2132 cvs_MD5Context ctx;
2133 uint8_t md5sum[16];
2134
2135 cvs_MD5Init(&ctx);
2136 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2137 cvs_MD5Final(md5sum, &ctx);
2138
2139 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2140 }
2141
2142 106 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2143 {
2144 106 zprint2("\n");
2145 106 zprint2("[ZQUEST CREATOR METADATA]\n");
2146
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if(qst_num < moduledata.max_quest_files)
2147 zprint2("Loading module quest %d\n", qst_num+1);
2148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(path) zprint2("Loading '%s'\n", path);
2149
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 4 times.
106 if ( tempheader.new_version_id_main > 0 )
2150 {
2151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(tempheader.new_version_id_fourth > 0)
2152 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2153 tempheader.new_version_id_main,tempheader.new_version_id_second,
2154 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2155 102 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2156 102 tempheader.new_version_id_main,tempheader.new_version_id_second,
2157 102 tempheader.new_version_id_third);
2158 102 }
2159 else
2160 {
2161
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2162 {
2163 case 0x255:
2164 {
2165 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2166 break;
2167 }
2168 case 0x254:
2169 {
2170 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2171 break;
2172 }
2173 case 0x250:
2174 {
2175 switch(tempheader.build)
2176 {
2177 case 19:
2178 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2179 case 20:
2180 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2181 case 21:
2182 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2183 case 22:
2184 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2185 case 23:
2186 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2187 case 24:
2188 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2189 case 25:
2190 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2191 case 26:
2192 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2193 case 27:
2194 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2195 case 28:
2196 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2197 case 29:
2198 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2199 case 30:
2200 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2201 case 31:
2202 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2203 case 32:
2204 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2205 case 33:
2206 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2207 default:
2208 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2209
2210 }
2211 break;
2212 }
2213
2214 case 0x211:
2215 {
2216 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2217 }
2218 case 0x210:
2219 {
2220 zprint2("Last saved in ZQuest Version: 2.10.x");
2221 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2222 break;
2223 }
2224 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2225 case 0x193:
2226 {
2227 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2228 }
2229 case 0x192:
2230 {
2231 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2232 }
2233 case 0x190:
2234 {
2235 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2236 }
2237 case 0x184:
2238 {
2239 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2240 }
2241 case 0x183:
2242 {
2243 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2244 }
2245 case 0x180:
2246 {
2247 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2248 }
2249 default:
2250 {
2251 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2252 }
2253 */
2254 }
2255 }
2256
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
106 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2257 21 zprint2("%s\n", tempheader.getAlphaVerStr());
2258 85 else zprint2("\n");
2259
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21 times.
106 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2260
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21 times.
106 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2261
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21 times.
106 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2262
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21 times.
106 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2263
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 102 times.
106 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2264
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21 times.
106 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2265 106 zprint2("\n");
2266 106 }
2267
2268 114 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2269 {
2270 int32_t dummy;
2271 zquestheader tempheader;
2272 char dummybuf[80];
2273 byte temp_map_count;
2274 byte temp_midi_flags[MIDIFLAGS_SIZE];
2275 word version;
2276 char temp_pwd[30], temp_pwd2[30];
2277 int16_t temp_pwdkey;
2278 cvs_MD5Context ctx;
2279 114 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2280 114 memset(&tempheader, 0, sizeof(tempheader));
2281 114 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2282
2283
2284
2285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2286 {
2287 Z_message("Unable to read header string\n");
2288 return qe_invalid;
2289 }
2290
2291 // check header
2292
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2293 {
2294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2295 {
2296 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2297 return qe_invalid;
2298 }
2299 4 }
2300
2301 114 int32_t templatepath_len=0;
2302
2303 114 tempheader.external_zinfo = false;
2304 114 read_zinfo = false;
2305
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2306 {
2307 byte padding;
2308
2309
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f,true))
2310 {
2311 return qe_invalid;
2312 }
2313
2314
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f,true))
2315 {
2316 return qe_invalid;
2317 }
2318
2319 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2320
2321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2322 {
2323 return qe_version;
2324 }
2325
2326 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2327
2328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2329 {
2330 return qe_invalid;
2331 }
2332
2333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2334 {
2335 return qe_obsolete;
2336 }
2337
2338
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f,true))
2339 {
2340 return qe_invalid;
2341 }
2342
2343
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f,true))
2344 {
2345 return qe_invalid;
2346 }
2347
2348 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2349
2350
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f,true))
2351 {
2352 return qe_invalid;
2353 }
2354
2355
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f,true))
2356 {
2357 return qe_invalid;
2358 }
2359
2360 4 FFCore.quest_format[qMapCount] = temp_map_count;
2361
2362
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f,true))
2363 {
2364 return qe_invalid;
2365 }
2366
2367
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2368 {
2369 return qe_invalid;
2370 }
2371
2372
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f,true))
2373 {
2374 return qe_invalid;
2375 }
2376
2377
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2378 {
2379 return qe_invalid;
2380 }
2381
2382
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f,true))
2383 {
2384 return qe_invalid;
2385 }
2386
2387
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f,true))
2388 {
2389 return qe_invalid;
2390 }
2391
2392
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f,true))
2393 {
2394 return qe_invalid;
2395 }
2396
2397
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f,true))
2398 {
2399 return qe_invalid;
2400 }
2401
2402
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2403 {
2404 return qe_invalid;
2405 }
2406 // These fields are expected to end in null bytes!
2407 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2408
2409
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2410 {
2411 return qe_invalid;
2412 }
2413 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2414
2415
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f,true))
2416 {
2417 return qe_invalid;
2418 }
2419
2420
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f,true))
2421 {
2422 return qe_invalid;
2423 }
2424
2425
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f,true))
2426 {
2427 return qe_invalid;
2428 }
2429
2430 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2431 4 cvs_MD5Init(&ctx);
2432 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2433 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2434
2435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2436 {
2437 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2438 // Not anymore...
2439 memset(tempheader.minver,0,17);
2440 tempheader.build=0;
2441 tempheader.use_keyfile=0;
2442 memset(tempheader.old_foo, 0, 9);
2443 }
2444 else
2445 {
2446
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f,true))
2447 {
2448 return qe_invalid;
2449 }
2450
2451
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f,true))
2452 {
2453 return qe_invalid;
2454 }
2455
2456 4 FFCore.quest_format[vBuild] = tempheader.build;
2457
2458
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f,true))
2459 {
2460 return qe_invalid;
2461 }
2462
2463
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f,true))
2464 {
2465 return qe_invalid;
2466 }
2467 } // starting at minver
2468
2469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2470 {
2471 memset(&quest_rules[4],0,16); // word rules3..rules10
2472 }
2473 else
2474 {
2475
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2476 {
2477 return qe_invalid; // starting at rules3
2478 }
2479
2480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2481 {
2482 4 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2483 4 }
2484 }
2485
2486
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2487 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2488 {
2489 4 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2490 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2491 4 }
2492
2493
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2494 {
2495 byte *mf=temp_midi_flags;
2496
2497 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2498 {
2499 mf=(byte*)dummybuf;
2500 }
2501
2502 if(!pfread(mf,32,f,true)) // read new header additions
2503 {
2504 return qe_invalid; // starting at foo2
2505 }
2506
2507 if(!pfread(dummybuf,18,f,true)) // read new header additions
2508 {
2509 return qe_invalid; // starting at foo2
2510 }
2511 }
2512
2513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2514 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2515 {
2516 4 memset(tempheader.templatepath,0,2048);
2517 4 }
2518 else
2519 {
2520 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2521 {
2522 return qe_invalid;
2523 }
2524 }
2525
2526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2527 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2528 {
2529 4 tempheader.use_keyfile=0;
2530 4 }
2531 4 }
2532 else
2533 {
2534 //section id
2535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(!p_mgetl(&dummy,f,true))
2536 {
2537 return qe_invalid;
2538 }
2539
2540 //section version info
2541
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&version,f,true))
2542 {
2543 return qe_invalid;
2544 }
2545
2546 110 FFCore.quest_format[vHeader] = version;
2547
2548
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy,f,true))
2549 {
2550 return qe_invalid;
2551 }
2552
2553 //section size
2554
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
2555 {
2556 return qe_invalid;
2557 }
2558
2559 //finally... section data
2560
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&tempheader.zelda_version,f,true))
2561 {
2562 return qe_invalid;
2563 }
2564
2565 110 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2566
2567 //do some quick checking...
2568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(tempheader.zelda_version > ZELDA_VERSION)
2569 {
2570 return qe_version;
2571 }
2572
2573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2574 {
2575 return qe_invalid;
2576 }
2577
2578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(bad_version(tempheader.zelda_version))
2579 {
2580 return qe_obsolete;
2581 }
2582
2583
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_getc(&tempheader.build,f,true))
2584 {
2585 return qe_invalid;
2586 }
2587
2588 110 FFCore.quest_format[vBuild] = tempheader.build;
2589
2590
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(version<3)
2591 {
2592
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!pfread(temp_pwd,30,f,true))
2593 {
2594 return qe_invalid;
2595 }
2596
2597
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&temp_pwdkey,f,true))
2598 {
2599 return qe_invalid;
2600 }
2601
2602 5 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2603 5 cvs_MD5Init(&ctx);
2604 5 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2605 5 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2606 5 }
2607 else
2608 {
2609
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2610 {
2611 return qe_invalid;
2612 }
2613 }
2614
2615
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&tempheader.internal,f,true))
2616 {
2617 return qe_invalid;
2618 }
2619
2620
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_getc(&tempheader.quest_number,f,true))
2621 {
2622 return qe_invalid;
2623 }
2624
2625 110 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2626
2627 110 size_t versz = version < 8 ? 9 : 16;
2628
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(tempheader.version,versz,f,true))
2629 {
2630 return qe_invalid;
2631 }
2632
2633 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2634 //needs to be copied as char[9] or stored as a s.str
2635
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(tempheader.minver,versz,f,true))
2636 {
2637 return qe_invalid;
2638 }
2639
2640 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2641
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2642 {
2643 return qe_invalid;
2644 }
2645 110 tempheader.title[sizeof(tempheader.title)-1] = 0;
2646
2647
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2648 {
2649 return qe_invalid;
2650 }
2651 110 tempheader.author[sizeof(tempheader.author)-1] = 0;
2652
2653
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_getc(&tempheader.use_keyfile,f,true))
2654 {
2655 return qe_invalid;
2656 }
2657
2658 /*
2659 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2660 {
2661 return qe_invalid;
2662 }
2663 */
2664
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2665 {
2666 return qe_invalid;
2667 }
2668
2669
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(&dummybuf,4,f,true))
2670 {
2671 return qe_invalid;
2672 }
2673
2674
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2675 {
2676 return qe_invalid;
2677 }
2678
2679
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(dummybuf,14,f,true))
2680 {
2681 return qe_invalid;
2682 }
2683
2684 110 templatepath_len=sizeof(tempheader.templatepath);
2685
2686
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(version==1)
2687 {
2688 5 templatepath_len=280;
2689 5 }
2690
2691
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2692 {
2693 return qe_invalid;
2694 }
2695
2696
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_getc(&temp_map_count,f,true))
2697 {
2698 return qe_invalid;
2699 }
2700
2701
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(version>=4)
2702 {
2703
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2704 {
2705 return qe_invalid;
2706 }
2707
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2708 {
2709 return qe_invalid;
2710 }
2711
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2712 {
2713 return qe_invalid;
2714 }
2715
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2716 {
2717 return qe_invalid;
2718 }
2719
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2720 {
2721 return qe_invalid;
2722 }
2723
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2724 {
2725 return qe_invalid;
2726 }
2727
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2728 {
2729 return qe_invalid;
2730 }
2731
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2732 {
2733 return qe_invalid;
2734 }
2735
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2736 {
2737 return qe_invalid;
2738 }
2739
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2740 {
2741 return qe_invalid;
2742 }
2743
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2744 {
2745 return qe_invalid;
2746 }
2747
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2748 {
2749 return qe_invalid;
2750 }
2751
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2752 {
2753 return qe_invalid;
2754 }
2755
2756
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.new_version_devsig,256,f,true))
2757 {
2758 return qe_invalid;
2759 }
2760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2761 strcpy(tempheader.new_version_devsig, "EmilyV99");
2762
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.new_version_compilername,256,f,true))
2763 {
2764 return qe_invalid;
2765 }
2766
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2767 {
2768 return qe_invalid;
2769 }
2770
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.product_name,1024,f,true))
2771 {
2772 return qe_invalid;
2773 }
2774
2775
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&tempheader.compilerid,f,true))
2776 {
2777 return qe_invalid;
2778 }
2779
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2780 {
2781 return qe_invalid;
2782 }
2783
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2784 {
2785 return qe_invalid;
2786 }
2787
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2788 {
2789 return qe_invalid;
2790 }
2791
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2792 {
2793 return qe_invalid;
2794 }
2795
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetw(&tempheader.developerid,f,true))
2796 {
2797 return qe_invalid;
2798 }
2799
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2800 {
2801 return qe_invalid;
2802 }
2803
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.build_datestamp,256,f,true))
2804 {
2805 return qe_invalid;
2806 }
2807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!pfread(tempheader.build_timestamp,256,f,true))
2808 {
2809 return qe_invalid;
2810 }
2811 29 }
2812 else // <4
2813 {
2814 81 tempheader.new_version_id_main = 0;
2815 81 tempheader.new_version_id_second = 0;
2816 81 tempheader.new_version_id_third = 0;
2817 81 tempheader.new_version_id_fourth = 0;
2818 81 tempheader.new_version_id_alpha = 0;
2819 81 tempheader.new_version_id_beta = 0;
2820 81 tempheader.new_version_id_gamma = 0;
2821 81 tempheader.new_version_id_release = 0;
2822 81 tempheader.new_version_id_date_year = 0;
2823 81 tempheader.new_version_id_date_month = 0;
2824 81 tempheader.new_version_id_date_day = 0;
2825 81 tempheader.new_version_id_date_hour = 0;
2826 81 tempheader.new_version_id_date_minute = 0;
2827
2828 81 memset(tempheader.new_version_devsig, 0, 256);
2829 81 memset(tempheader.new_version_compilername, 0, 256);
2830 81 memset(tempheader.new_version_compilerversion, 0, 256);
2831 81 memset(tempheader.product_name, 0, 1024);
2832 81 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2833
2834 81 tempheader.compilerid = 0;
2835 81 tempheader.compilerversionnumber_first = 0;
2836 81 tempheader.compilerversionnumber_second = 0;
2837 81 tempheader.compilerversionnumber_third = 0;
2838 81 tempheader.compilerversionnumber_fourth = 0;
2839 81 tempheader.developerid = 0;
2840
2841 81 memset(tempheader.made_in_module_name, 0, 1024);
2842 81 memset(tempheader.build_datestamp, 0, 256);
2843 81 memset(tempheader.build_timestamp, 0, 256);
2844 }
2845
2846
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if ( version >= 5 )
2847 {
2848
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!pfread(tempheader.build_timezone,6,f,true))
2849 {
2850 return qe_invalid;
2851 }
2852 29 }
2853 else // < 5
2854 {
2855 81 memset(tempheader.build_timezone, 0, 6);
2856 }
2857
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if ( version >= 6 )
2858 {
2859 byte b;
2860
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&b,f,true))
2861 {
2862 return qe_invalid;
2863 }
2864 29 tempheader.external_zinfo = b?true:false;
2865 29 read_zinfo = true;
2866 29 }
2867
2868
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(version >= 7)
2869 {
2870
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2871 {
2872 return qe_invalid;
2873 }
2874 29 }
2875 else
2876 {
2877 81 tempheader.new_version_is_nightly = false;
2878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(tempheader.zelda_version < 0x255)
2879 {
2880
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
81 switch(tempheader.zelda_version)
2881 {
2882 case 0x254:
2883 tempheader.new_version_id_main = 2;
2884 tempheader.new_version_id_second = 54;
2885 break;
2886 case 0x250:
2887
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 1 times.
76 switch(tempheader.build)
2888 {
2889 case 19:
2890 tempheader.new_version_id_main = 2;
2891 tempheader.new_version_id_second = 50;
2892 tempheader.new_version_id_gamma = 1;
2893 break;
2894 case 20:
2895 tempheader.new_version_id_main = 2;
2896 tempheader.new_version_id_second = 50;
2897 tempheader.new_version_id_gamma = 2;
2898 break;
2899 case 21:
2900 tempheader.new_version_id_main = 2;
2901 tempheader.new_version_id_second = 50;
2902 tempheader.new_version_id_gamma = 3;
2903 break;
2904 case 22:
2905 tempheader.new_version_id_main = 2;
2906 tempheader.new_version_id_second = 50;
2907 tempheader.new_version_id_gamma = 4;
2908 break;
2909 case 23:
2910 tempheader.new_version_id_main = 2;
2911 tempheader.new_version_id_second = 50;
2912 tempheader.new_version_id_gamma = 5;
2913 break;
2914 case 24:
2915 22 tempheader.new_version_id_main = 2;
2916 22 tempheader.new_version_id_second = 50;
2917 22 tempheader.new_version_id_release = -1;
2918 22 break;
2919 case 25:
2920 tempheader.new_version_id_main = 2;
2921 tempheader.new_version_id_second = 50;
2922 tempheader.new_version_id_third = 1;
2923 tempheader.new_version_id_gamma = 1;
2924 break;
2925 case 26:
2926 tempheader.new_version_id_main = 2;
2927 tempheader.new_version_id_second = 50;
2928 tempheader.new_version_id_third = 1;
2929 tempheader.new_version_id_gamma = 2;
2930 break;
2931 case 27:
2932 tempheader.new_version_id_main = 2;
2933 tempheader.new_version_id_second = 50;
2934 tempheader.new_version_id_third = 1;
2935 tempheader.new_version_id_gamma = 3;
2936 break;
2937 case 28:
2938 5 tempheader.new_version_id_main = 2;
2939 5 tempheader.new_version_id_second = 50;
2940 5 tempheader.new_version_id_third = 1;
2941 5 tempheader.new_version_id_release = -1;
2942 5 break;
2943 case 29:
2944 24 tempheader.new_version_id_main = 2;
2945 24 tempheader.new_version_id_second = 50;
2946 24 tempheader.new_version_id_third = 2;
2947 24 tempheader.new_version_id_release = -1;
2948 24 break;
2949 case 30:
2950 tempheader.new_version_id_main = 2;
2951 tempheader.new_version_id_second = 50;
2952 tempheader.new_version_id_third = 3;
2953 tempheader.new_version_id_gamma = 1;
2954 break;
2955 case 31:
2956 15 tempheader.new_version_id_main = 2;
2957 15 tempheader.new_version_id_second = 53;
2958 15 tempheader.new_version_id_gamma = -1;
2959 15 break;
2960 case 32:
2961 9 tempheader.new_version_id_main = 2;
2962 9 tempheader.new_version_id_second = 53;
2963 9 tempheader.new_version_id_release = -1;
2964 9 break;
2965 case 33:
2966 1 tempheader.new_version_id_main = 2;
2967 1 tempheader.new_version_id_second = 53;
2968 1 tempheader.new_version_id_third = 1;
2969 1 break;
2970 }
2971 76 break;
2972
2973 case 0x211:
2974 tempheader.new_version_id_main = 2;
2975 tempheader.new_version_id_second = 11;
2976 tempheader.new_version_id_beta = tempheader.build;
2977 break;
2978 case 0x210:
2979 5 tempheader.new_version_id_main = 2;
2980 5 tempheader.new_version_id_second = 10;
2981 5 tempheader.new_version_id_beta = tempheader.build;
2982 5 break;
2983 }
2984 81 }
2985 }
2986
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
110 if(printmetadata || __isZQuest)
2987 {
2988 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2989 }
2990 }
2991
2992 //{ Version Warning
2993 114 int32_t vercmp = tempheader.compareVer();
2994 114 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2995 114 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2996
4/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
143 if(vercmp > 0 || (!vercmp &&
2997
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 (astatecmp > 0 || (!astatecmp &&
2998 29 avercmp > 0))))
2999 {
3000 bool r = true;
3001 if(loadquest_report)
3002 {
3003 enter_sys_pal();
3004 AlertDialog("Quest saved in newer version",
3005 "This quest was last saved in a newer version of ZQuest."
3006 " Attempting to load this quest may not work correctly; to"
3007 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
3008 "\n\nWould you like to continue loading anyway? (Not recommended)",
3009 [&](bool ret,bool)
3010 {
3011 r = ret;
3012 }).show();
3013 exit_sys_pal();
3014 }
3015 if(!r)
3016 return qe_silenterr;
3017 }
3018
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 else if(tempheader.compareDate() > 0)
3019 {
3020 bool r = true;
3021 if(loadquest_report)
3022 {
3023 enter_sys_pal();
3024 AlertDialog("Quest saved in newer build",
3025 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
3026 " issues loading in this build."
3027 "\n{}"
3028 "\n\nWould you like to continue loading anyway?",
3029 tempheader.getVerCmpStr()),
3030 [&](bool ret,bool)
3031 {
3032 r = ret;
3033 }).show();
3034 exit_sys_pal();
3035 }
3036 if(!r)
3037 return qe_silenterr;
3038 }
3039 //}
3040
3041 114 read_ext_zinfo = tempheader.external_zinfo;
3042
3043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
3044 {
3045 114 memcpy(Header, &tempheader, sizeof(tempheader));
3046 114 map_count=temp_map_count;
3047 114 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
3048 114 }
3049
3050 114 return 0;
3051 114 }
3052
3053 116 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
3054 {
3055 int32_t dummy;
3056 zquestheader tempheader;
3057 116 word s_version=0;
3058 116 dword compatrule_version=0;
3059
3060 116 memcpy(&tempheader, Header, sizeof(tempheader));
3061
3062
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 110 times.
116 if(tempheader.zelda_version >= 0x193)
3063 {
3064 //section version info
3065
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
3066 {
3067 return qe_invalid;
3068 }
3069
3070 110 FFCore.quest_format[vRules] = s_version;
3071
3072
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy,f,true))
3073 {
3074 return qe_invalid;
3075 }
3076
3077
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if(s_version > 16)
3078 {
3079
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&compatrule_version,f,true))
3080 {
3081 return qe_invalid;
3082 }
3083 29 }
3084 110 FFCore.quest_format[vCompatRule] = compatrule_version;
3085
3086 //section size
3087
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
3088 {
3089 return qe_invalid;
3090 }
3091
3092
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if ( s_version < 15 )
3093 {
3094 //finally... section data
3095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
3096 {
3097 return qe_invalid;
3098 }
3099 81 }
3100 else
3101 {
3102
3103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
3104 {
3105 return qe_invalid;
3106 }
3107
3108 }
3109 110 }
3110
3111 //al_trace("Rules version %d\n", s_version);
3112 //{ bunch of compat stuff
3113 116 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
3114
3115
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 9 times.
116 if(s_version<2)
3116 {
3117 9 set_bit(quest_rules,14,0);
3118 9 set_bit(quest_rules,27,0);
3119 9 set_bit(quest_rules,28,0);
3120 9 set_bit(quest_rules,29,0);
3121 9 set_bit(quest_rules,30,0);
3122 9 set_bit(quest_rules,32,0);
3123 9 set_bit(quest_rules,36,0);
3124 9 set_bit(quest_rules,49,0);
3125 9 set_bit(quest_rules,50,0);
3126 9 set_bit(quest_rules,51,0);
3127 9 set_bit(quest_rules,68,0);
3128 9 set_bit(quest_rules,75,0);
3129 9 set_bit(quest_rules,76,0);
3130 9 set_bit(quest_rules,98,0);
3131 9 set_bit(quest_rules,110,0);
3132 9 set_bit(quest_rules,113,0);
3133 9 set_bit(quest_rules,116,0);
3134 9 set_bit(quest_rules,102,0);
3135 9 set_bit(quest_rules,132,0);
3136 9 }
3137
3138 //Now, do any updates...
3139
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
116 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3140 {
3141 13 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3142 13 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3143 13 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3144 13 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3145 13 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3146 13 }
3147
3148
5/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
116 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3149 {
3150 8 set_bit(quest_rules,qr_WALLFLIERS,1);
3151 8 }
3152
3153
5/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
116 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3154 {
3155 8 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3156 8 }
3157
3158
5/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
116 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3159 {
3160 8 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3161 8 }
3162
3163
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 9 times.
116 if(tempheader.zelda_version <= 0x210)
3164 {
3165 9 set_bit(quest_rules,qr_ARROWCLIP,1);
3166 9 }
3167
3168
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 5 times.
116 if(tempheader.zelda_version == 0x210)
3169 {
3170 5 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3171 5 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3172 5 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3173 5 }
3174
3175
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 9 times.
116 if(tempheader.zelda_version <= 0x210)
3176 {
3177 9 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3178 9 set_bit(quest_rules,qr_210_WARPRETURN,1);
3179 9 }
3180
3181 //might not be correct
3182
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 4 times.
116 if(tempheader.zelda_version < 0x210)
3183 {
3184 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3185 4 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3186 4 }
3187
3188
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 9 times.
116 if(tempheader.zelda_version < 0x211)
3189 {
3190 9 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3191 9 }
3192
3193
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
116 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3194 {
3195 set_bit(quest_rules, qr_192b163_WARP,1);
3196 }
3197
3198
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 5 times.
116 if(tempheader.zelda_version == 0x210)
3199 {
3200 5 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3201 5 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3202 5 }
3203
3204
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
116 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3205 {
3206 13 set_bit(quest_rules, qr_OLDPICKUP,1);
3207 13 }
3208
3209
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
116 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3210 {
3211 13 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3212 13 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3213 13 }
3214
3215
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 9 times.
116 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3216 {
3217 9 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3218 9 }
3219
3220
4/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 22 times.
116 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3221 {
3222 22 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3223 22 }
3224
3225
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 78 times.
116 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3226 {
3227 13 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3228 13 }
3229
3230
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 78 times.
116 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3231 {
3232 13 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3233 13 }
3234
3235
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 56 times.
116 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3236 {
3237 35 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3238 35 }
3239
3240
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 56 times.
116 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3241 {
3242 35 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3243 35 }
3244
3245 //Bombchu fix.
3246
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 76 times.
116 if(tempheader.zelda_version == 0x250)
3247 {
3248
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 22 times.
76 if ( tempheader.build == 24 ) //2.50.0
3249 {
3250 22 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3251 22 }
3252
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 5 times.
76 if ( tempheader.build == 28 ) //2.50.1
3253 {
3254 5 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3255 5 }
3256
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 24 times.
76 if ( tempheader.build == 29 ) //2.50.2
3257 {
3258 24 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3259 24 }
3260
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( tempheader.build == 30 ) //2.50.3RC1
3261 {
3262 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3263 }
3264 76 }
3265
3266
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 51 times.
116 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3267 {
3268 // qr_OFFSETEWPNCOLLISIONFIX
3269 // All 'official' quests need this disabled.
3270 // All 2.10 and lower quests need this enabled to preseve compatability.
3271 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3272
3273 //~Gleeok
3274 36 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3275
3276 // Broke in build 695
3277
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
36 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3278 27 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3279 36 }
3280
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 4 times.
116 if (tempheader.zelda_version <= 0x190)
3281 {
3282 4 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3283 4 }
3284
9/10
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 29 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 29 times.
116 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3285 {
3286 86 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3287 86 }
3288
3289
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3290 {
3291 9 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3292 9 }
3293
3294
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3295 {
3296 85 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3297 85 }
3298
3299
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if ( tempheader.zelda_version < 0x250 )
3300 {
3301 9 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3302 9 }
3303
3304
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version < 3)
3305 {
3306 9 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3307 9 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3308 9 }
3309
3310
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<4)
3311 {
3312 9 set_bit(quest_rules,10,0);
3313 9 }
3314
3315
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<5)
3316 {
3317 9 set_bit(quest_rules,27,0);
3318 9 }
3319
3320
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<6)
3321 {
3322 9 set_bit(quest_rules,46,0);
3323 9 }
3324
3325
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<7) // January 2008
3326 {
3327 9 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3328 9 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3329 9 }
3330
3331
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
114 if(s_version<8)
3332 {
3333 9 set_bit(quest_rules, 12, 0);
3334 9 }
3335 else
3336 {
3337 105 set_bit(deprecated_rules, 12, 0);
3338 }
3339
3340
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<9) // October 2008
3341 {
3342 9 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3343 9 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3344 9 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3345 9 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3346 9 }
3347
3348
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<10) // December 2008
3349 {
3350 9 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3351 9 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3352 9 }
3353
3354
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<11) // April 2009
3355 {
3356 9 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3357 9 }
3358
3359
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<12) // December 2009
3360 {
3361 9 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3362 9 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3363 9 }
3364
3365 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3366
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version < 13)
3367 {
3368 9 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3369 9 }
3370
3371 // Not entirely sure this is the best place for this...
3372 //2.50.2 bitmap offset fix
3373 114 memset(extra_rules, 0, EXTRARULES_SIZE);
3374
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 49 times.
114 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3375 {
3376 36 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3377 36 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3378 36 }
3379 //required because quest templates also used this bit, although
3380 //it never did anything, before. -Z
3381
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 76 times.
114 if ( tempheader.zelda_version == 0x250 )
3382 {
3383
5/6
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 37 times.
76 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3384 {
3385 39 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3386 39 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3387 39 }
3388 76 }
3389
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if ( tempheader.zelda_version == 0x254 )
3390 {
3391 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3392 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3393 }
3394
3/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
114 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3395 {
3396 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3397 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3398 }
3399 //optimise fast drawing for older versions.
3400
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3401 {
3402 85 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3403 85 }
3404 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3405 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3406 //older quests can set the rule by hand. We need a new qst.dat again.
3407
4/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3408 {
3409 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3410 }
3411
4/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3412 {
3413 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3414 }
3415
4/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3416 {
3417 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3418 }
3419
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if ( tempheader.zelda_version < 0x254 )
3420 {
3421 85 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3422 85 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3423 85 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3424 85 }
3425
3426 //item scripts continue to run
3427
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3428 {
3429 85 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3430 85 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3431 85 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3432 85 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3433 85 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3434 85 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3435 85 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3436 85 }
3437
3438
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3439 {
3440 85 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3441 85 }
3442
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3443 {
3444 85 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3445 85 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3446 85 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3447 85 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3448 85 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3449 85 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3450 85 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3451 85 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3452
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 2 times.
85 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3453 {
3454 2 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3455 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3456 //Now they **do**, unless you disable that behaviour.
3457 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3458 //now enable the disable L/R item swap on load.
3459 2 }
3460
3461 85 }
3462
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3463 {
3464 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3465 85 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3466 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3467 //animations ending earlier than they should.
3468 85 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3469 //Enemies would ignore solidity on the top half of combos
3470 85 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3471 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3472 85 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3473 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3474 85 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3475 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3476 85 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3477 85 }
3478
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if ( tempheader.zelda_version < 0x255 )
3479 {
3480 85 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3481 85 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3482 85 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3483 85 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3484 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3485 85 }
3486
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3487 {
3488 85 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3489 85 }
3490
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3491 {
3492 85 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3493 85 }
3494
3495
3496
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3497 {
3498 85 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3499 85 }
3500
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3501 {
3502 85 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3503 85 }
3504
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3505 {
3506 85 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3507 85 }
3508
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3509 {
3510 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3511
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3512 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3513 85 }
3514
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3515 {
3516 85 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3517 85 }
3518
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3519 {
3520 85 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3521 85 }
3522
3523
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if ( tempheader.zelda_version < 0x254 )
3524 {
3525 85 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3526 85 }
3527 //Sideview spikes in 2.50.0
3528
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 54 times.
114 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3529 {
3530 31 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3531 31 }
3532 //more 2.50 fixes -Z
3533
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 25 times.
114 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3534 {
3535 60 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3536 60 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3537 60 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3538 60 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3539 60 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3540
3541 60 }
3542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3543 {
3544 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3545 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3546 }
3547
3548
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(tempheader.zelda_version < 0x193)
3549 {
3550 4 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3551 4 }
3552
3553
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(tempheader.zelda_version < 0x255)
3554 {
3555 85 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3556 85 }
3557
3558
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3559 {
3560 9 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3561 9 }
3562
3563
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3564 {
3565 85 set_bit(quest_rules,qr_OLD_F6,1);
3566 85 }
3567
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3568 {
3569 85 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3570 85 }
3571
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3572 {
3573 85 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3574 85 }
3575
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3576 {
3577 85 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3578 85 }
3579 //}
3580
3581
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3582 85 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3583
3584
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 2) //Old CSet2 Handling
3585 85 set_bit(quest_rules,qr_OLDCS2,1);
3586
3587
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3588 85 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3589
3590
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3591 85 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3592
3593
4/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 76 times.
114 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3594 76 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3595
3596
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3597 85 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3598
3599
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3600 85 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3601
3602
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3603 85 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3604
3605
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 9)
3606 {
3607 //Hardcoded BS Patras
3608 85 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3609 //Hardcoded Patra Inner Eye offsets
3610 85 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3611 //Broken 'Big enemy' animation style
3612 85 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3613 //Broken Attribute 31/32
3614 85 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3615 85 }
3616
3617
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 10) //Shared candle use limits
3618 85 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3619
3620
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 11) //No cross-screen return points
3621 85 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3622
3623
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 12)
3624 {
3625 //Old fire trail duration
3626 85 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3627 //Old Intro String in Ganon Room Behavior
3628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3629 85 else set_bit(quest_rules,qr_GANONINTRO,1);
3630 85 }
3631
3632
3/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 85 times.
✗ Branch 3 not taken.
114 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3633 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3634
3635
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 14) //Old Bridge Combo Behavior
3636 85 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3637
3638
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 15) //Broken Z3 Animation
3639 85 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3640
3641
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3642 85 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3643
3644
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 17)
3645 {
3646 //Old Quake/DrawYOffset behavior
3647 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3648 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3649 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3650 85 }
3651
3652
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 18)
3653 {
3654 //Broken DrawScreen Derivative Functions
3655 85 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3656 //Scrolling Cancels Charge
3657 85 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3658 85 }
3659
3660
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3661 85 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3662
3663
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 20)
3664 85 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3665
3666
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 21)
3667 {
3668 85 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3669 85 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3670 85 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3671 85 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3672 85 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3673 85 }
3674
3675
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 22)
3676 85 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3677
3678
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 23)
3679 85 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3680
3681
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 24)
3682 {
3683 85 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3684 85 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3685 85 }
3686
3687
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 25)
3688 {
3689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3690 85 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3691 85 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3692 85 }
3693
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 26)
3694 {
3695 85 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3696 85 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3697 85 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3698 85 }
3699
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3700 {
3701
2/2
✓ Branch 0 taken 25585 times.
✓ Branch 1 taken 85 times.
25670 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3702 25585 set_bit(quest_rules,q,0);
3703
2/2
✓ Branch 0 taken 9520 times.
✓ Branch 1 taken 85 times.
9605 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3704 9520 set_bit(quest_rules,q,0);
3705 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3706 85 }
3707
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 28)
3708 87 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3709
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 29)
3710 87 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3711
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 30)
3712 {
3713 87 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3714 87 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3715 87 }
3716
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 31)
3717 {
3718 87 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3719 87 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3720 87 }
3721
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 32)
3722 87 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3723
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 33)
3724 87 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3725
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(compatrule_version < 34)
3726 {
3727 87 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3728 87 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3729 87 set_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY,1);
3730 87 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3731 87 }
3732
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 88 times.
114 if(compatrule_version < 35)
3733 {
3734 // Leaving this commented for now, might need to enable later -Em
3735 // set_bit(quest_rules,qr_ZS_NO_NEG_ARRAY,1);
3736 88 }
3737
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 88 times.
114 if(compatrule_version < 36)
3738 88 set_bit(quest_rules,qr_OLD_SHALLOW_SFX,1);
3739
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 90 times.
114 if(compatrule_version < 37)
3740 90 set_bit(quest_rules,qr_SPARKLES_INHERIT_PROPERTIES,1);
3741
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 90 times.
114 if(compatrule_version < 38)
3742 90 set_bit(quest_rules,qr_BUGGED_LAYERED_FLAGS,1);
3743
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 90 times.
114 if(compatrule_version < 39)
3744 90 set_bit(quest_rules,qr_HARDCODED_FFC_BUSH_DROPS,1);
3745
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 90 times.
114 if(compatrule_version < 40)
3746 90 set_bit(quest_rules,qr_MOVINGBLOCK_FAKE_SOLID,1);
3747
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 91 times.
114 if(compatrule_version < 41)
3748 91 set_bit(quest_rules,qr_BROKENHITBY,1);
3749
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 91 times.
114 if(compatrule_version < 42)
3750 91 set_bit(quest_rules,qr_BROKEN_MOVING_BOMBS,1);
3751
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 91 times.
114 if(compatrule_version < 43)
3752 91 set_bit(quest_rules,qr_OLD_BOMB_HITBOXES,1);
3753
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 91 times.
114 if(compatrule_version < 44)
3754 91 set_bit(quest_rules,qr_SCROLLWARP_NO_RESET_FRAME,1);
3755
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 102 times.
114 if(compatrule_version < 45)
3756 102 set_bit(quest_rules,qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(compatrule_version < 46)
3758 114 set_bit(quest_rules,qr_BROKEN_RAFT_SCROLL,1);
3759
3760 114 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3761
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if (s_version < 16)
3762 85 set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3763
3764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
3765 114 memcpy(Header, &tempheader, sizeof(tempheader));
3766
3767 114 return 0;
3768 114 }
3769
3770 947040 void init_msgstr(MsgStr *str)
3771 {
3772 947040 str->s = "";
3773 947040 str->s.shrink_to_fit();
3774 947040 str->nextstring=0;
3775 947040 str->tile=0;
3776 947040 str->cset=0;
3777 947040 str->trans=false;
3778 947040 str->font=font_zfont;
3779 947040 str->y=32;
3780 947040 str->sfx=18;
3781 947040 str->listpos=0;
3782 947040 str->x=24;
3783 947040 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3784 947040 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3785 947040 str->hspace=0;
3786 947040 str->vspace=0;
3787 947040 str->stringflags=0;
3788 947040 str->margins[up] = 8;
3789 947040 str->margins[down] = 0;
3790 947040 str->margins[left] = 8;
3791 947040 str->margins[right] = 0;
3792 947040 str->portrait_tile = 0;
3793 947040 str->portrait_cset = 0;
3794 947040 str->portrait_x = 0;
3795 947040 str->portrait_y = 0;
3796 947040 str->portrait_tw = 1;
3797 947040 str->portrait_th = 1;
3798 947040 str->shadow_type = 0;
3799 947040 str->shadow_color = 0;
3800 947040 str->drawlayer = 6;
3801 947040 }
3802
3803 114 void init_msgstrings(int32_t start, int32_t end)
3804 {
3805
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(end <= start || end-start > msg_strings_size)
3806 return;
3807
3808
2/2
✓ Branch 0 taken 933888 times.
✓ Branch 1 taken 114 times.
934002 for(int32_t i=start; i<end; i++)
3809 {
3810 933888 init_msgstr(&MsgStrings[i]);
3811 933888 MsgStrings[i].listpos=i;
3812 933888 }
3813
3814
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(start==0)
3815 {
3816 114 MsgStrings[0].s = "(None)";
3817 114 MsgStrings[0].listpos = 0;
3818 114 }
3819 114 }
3820
3821 114 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3822 {
3823 114 MsgStr tempMsgString;
3824
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 init_msgstr(&tempMsgString);
3825
3826 114 word temp_msg_count=0;
3827 word temp_expansion[16];
3828 114 memset(temp_expansion, 0, 16*sizeof(word));
3829 114 char buf[8193] = {0};
3830
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version < 0x193)
3831 {
3832 byte tempbyte;
3833 4 int32_t strings_to_read=0;
3834
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3835
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3836 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3837 {
3838 4 strings_to_read=128;
3839 4 temp_msg_count=Header->old_str_count;
3840
3841 // Some sort of string count corruption seems to be common in old quests
3842
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3843 {
3844 temp_msg_count=128;
3845 }
3846 4 }
3847 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3848 {
3849 strings_to_read=255;
3850 temp_msg_count=Header->old_str_count;
3851 }
3852 else
3853 {
3854 if(!p_igetw(&temp_msg_count,f,true))
3855 {
3856 return qe_invalid;
3857 }
3858
3859 strings_to_read=temp_msg_count;
3860
3861 if(temp_msg_count >= msg_strings_size)
3862 {
3863 Z_message("Reallocating string buffer...\n");
3864
3865 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3866 // return qe_nomem;
3867
3868 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3869 delete[] MsgStrings;
3870 MsgStrings = new MsgStr[MAXMSGS];
3871 msg_strings_size = MAXMSGS;
3872 for(auto q = 0; q < msg_strings_size; ++q)
3873 {
3874 MsgStrings[q].clear();
3875 }
3876 }
3877 }
3878
3879 //reset the message strings
3880
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(keepdata)
3881 {
3882
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3883 4 }
3884
3885
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3886 {
3887
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3888
3889
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f,true))
3890 {
3891 return qe_invalid;
3892 }
3893
3894 512 buf[74] = '\0';
3895
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3896
3897
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3898 {
3899 return qe_invalid;
3900 }
3901
3902
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3903 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3904 {
3905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3906
3907
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3908 {
3909 return qe_invalid;
3910 }
3911
3912
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3913 {
3914 return qe_invalid;
3915 }
3916 512 }
3917 else
3918 {
3919 if(!p_igetw(&tempMsgString.nextstring,f,true))
3920 {
3921 return qe_invalid;
3922 }
3923
3924 if(!pfread(temp_expansion,32,f,true))
3925 {
3926 return qe_invalid;
3927 }
3928 }
3929
3930
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(keepdata==true)
3931 {
3932
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3933 512 }
3934 512 }
3935 4 }
3936 else
3937 {
3938 int32_t dummy_int;
3939 word s_version;
3940 word s_cversion;
3941
3942 //section version info
3943
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&s_version,f,true))
3944 {
3945 return qe_invalid;
3946 }
3947
3948 110 FFCore.quest_format[vStrings] = s_version;
3949
3950
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&s_cversion,f,true))
3951 {
3952 return qe_invalid;
3953 }
3954
3955 //al_trace("Strings version %d\n", s_version);
3956 //section size
3957
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetl(&dummy_int,f,true))
3958 {
3959 return qe_invalid;
3960 }
3961
3962 //finally... section data
3963
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&temp_msg_count,f,true))
3964 {
3965 return qe_invalid;
3966 }
3967
3968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(temp_msg_count >= msg_strings_size)
3969 {
3970 Z_message("Reallocating string buffer...\n");
3971
3972 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3973 // return qe_nomem;
3974 delete[] MsgStrings;
3975 MsgStrings = new MsgStr[MAXMSGS];
3976 msg_strings_size = MAXMSGS;
3977 for(auto q = 0; q < msg_strings_size; ++q)
3978 {
3979 MsgStrings[q].clear();
3980 }
3981 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3982 }
3983
3984 //reset the message strings
3985
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(keepdata)
3986 {
3987
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if(s_version < 7)
3988
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3989
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 init_msgstrings(0,msg_strings_size);
3990 110 }
3991
3992 110 int32_t string_length=(s_version<2)?73:145;
3993
3994
2/2
✓ Branch 0 taken 12526 times.
✓ Branch 1 taken 110 times.
12636 for(int32_t i=0; i<temp_msg_count; i++)
3995 {
3996
1/2
✓ Branch 0 taken 12526 times.
✗ Branch 1 not taken.
12526 init_msgstr(&tempMsgString);
3997
2/2
✓ Branch 0 taken 878 times.
✓ Branch 1 taken 11648 times.
12526 if(s_version > 8)
3998 {
3999
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_igetl(&string_length,f,true))
4000 {
4001 return qe_invalid;
4002 }
4003 878 }
4004
2/2
✓ Branch 0 taken 12388 times.
✓ Branch 1 taken 138 times.
12526 if (string_length > 0)
4005 {
4006
2/4
✓ Branch 0 taken 12388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12388 times.
✗ Branch 3 not taken.
12388 if (!pfread(buf, string_length, f, true))
4007 {
4008 return qe_invalid;
4009 }
4010 12388 }
4011 else
4012 {
4013 138 buf[0] = 0;
4014 }
4015
4016
2/4
✓ Branch 0 taken 12526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12526 times.
✗ Branch 3 not taken.
12526 if(!p_igetw(&tempMsgString.nextstring,f,true))
4017 {
4018 return qe_invalid;
4019 }
4020
4021
2/2
✓ Branch 0 taken 4646 times.
✓ Branch 1 taken 7880 times.
12526 if(s_version<2)
4022 {
4023 4646 buf[72] = '\0';
4024
1/2
✓ Branch 0 taken 4646 times.
✗ Branch 1 not taken.
4646 tempMsgString.s = buf;
4025 4646 }
4026 else
4027 {
4028 // June 2008: A bug corrupted the last 4 chars of a string.
4029 // Discard these.
4030
1/2
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
7880 if(s_version<3)
4031 {
4032 for(int32_t j=140; j<144; j++)
4033 {
4034 buf[j] = '\0';
4035 }
4036 }
4037
1/2
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
7880 if(string_length > 8192) string_length = 8192;
4038 7880 buf[string_length]='\0'; //Force-terminate
4039
1/2
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
7880 tempMsgString.s = buf;
4040
4041
2/2
✓ Branch 0 taken 878 times.
✓ Branch 1 taken 7002 times.
7880 if ( s_version >= 6 )
4042 {
4043
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_igetl(&tempMsgString.tile,f,true))
4044 {
4045 return qe_invalid;
4046 }
4047 878 }
4048 else
4049 {
4050
2/4
✓ Branch 0 taken 7002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7002 times.
✗ Branch 3 not taken.
7002 if(!p_igetw(&tempMsgString.tile,f,true))
4051 {
4052 return qe_invalid;
4053 }
4054 }
4055
4056
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&tempMsgString.cset,f,true))
4057 {
4058 return qe_invalid;
4059 }
4060
4061 byte dummy_char;
4062
4063
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
4064 {
4065 return qe_invalid;
4066 }
4067
4068 7880 tempMsgString.trans=dummy_char!=0;
4069
4070
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&tempMsgString.font,f,true))
4071 {
4072 return qe_invalid;
4073 }
4074
4075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7880 times.
7880 if(s_version < 5)
4076 {
4077 if(!p_getc(&tempMsgString.y,f,true))
4078 {
4079 return qe_invalid;
4080 }
4081 }
4082 else
4083 {
4084
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_igetw(&tempMsgString.x,f,true))
4085 {
4086 return qe_invalid;
4087 }
4088
4089
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_igetw(&tempMsgString.y,f,true))
4090 {
4091 return qe_invalid;
4092 }
4093
4094
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_igetw(&tempMsgString.w,f,true))
4095 {
4096 return qe_invalid;
4097 }
4098
4099
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_igetw(&tempMsgString.h,f,true))
4100 {
4101 return qe_invalid;
4102 }
4103
4104
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&tempMsgString.hspace,f,true))
4105 {
4106 return qe_invalid;
4107 }
4108
4109
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&tempMsgString.vspace,f,true))
4110 {
4111 return qe_invalid;
4112 }
4113
4114
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&tempMsgString.stringflags,f,true))
4115 {
4116 return qe_invalid;
4117 }
4118 }
4119
4120
2/2
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 878 times.
7880 if(s_version >= 7)
4121 {
4122
2/2
✓ Branch 0 taken 878 times.
✓ Branch 1 taken 3512 times.
4390 for(int32_t q = 0; q < 4; ++q)
4123 {
4124
2/4
✓ Branch 0 taken 3512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3512 times.
✗ Branch 3 not taken.
3512 if(!p_getc(&tempMsgString.margins[q],f,true))
4125 {
4126 return qe_invalid;
4127 }
4128 3512 }
4129
4130
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
4131 {
4132 return qe_invalid;
4133 }
4134
4135
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.portrait_cset,f,true))
4136 {
4137 return qe_invalid;
4138 }
4139
4140
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.portrait_x,f,true))
4141 {
4142 return qe_invalid;
4143 }
4144
4145
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.portrait_y,f,true))
4146 {
4147 return qe_invalid;
4148 }
4149
4150
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4151 {
4152 return qe_invalid;
4153 }
4154
4155
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.portrait_th,f,true))
4156 {
4157 return qe_invalid;
4158 }
4159 878 }
4160
4161
2/2
✓ Branch 0 taken 878 times.
✓ Branch 1 taken 7002 times.
7880 if(s_version >= 8)
4162 {
4163
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.shadow_type,f,true))
4164 {
4165 return qe_invalid;
4166 }
4167
4168
2/4
✓ Branch 0 taken 878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 878 times.
✗ Branch 3 not taken.
878 if(!p_getc(&tempMsgString.shadow_color,f,true))
4169 {
4170 return qe_invalid;
4171 }
4172 878 }
4173
4174
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 7119 times.
7880 if(s_version >= 10)
4175 {
4176
2/4
✓ Branch 0 taken 761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 761 times.
✗ Branch 3 not taken.
761 if(!p_getc(&tempMsgString.drawlayer,f,true))
4177 {
4178 return qe_invalid;
4179 }
4180 761 }
4181
4182
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_getc(&tempMsgString.sfx,f,true))
4183 {
4184 return qe_invalid;
4185 }
4186
4187
1/2
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
7880 if(s_version>3)
4188 {
4189
2/4
✓ Branch 0 taken 7880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7880 times.
✗ Branch 3 not taken.
7880 if(!p_igetw(&tempMsgString.listpos,f,true))
4190 {
4191 return qe_invalid;
4192 }
4193 7880 }
4194 }
4195
4196
1/2
✓ Branch 0 taken 12526 times.
✗ Branch 1 not taken.
12526 if(keepdata==true)
4197 {
4198
1/2
✓ Branch 0 taken 12526 times.
✗ Branch 1 not taken.
12526 MsgStrings[i].copyAll(tempMsgString);
4199 12526 }
4200 12526 }
4201 }
4202
4203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
4204 {
4205 114 msg_count=temp_msg_count;
4206 114 }
4207
4208 114 return 0;
4209 114 }
4210
4211 114 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4212 {
4213
2/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if((Header->zelda_version < 0x192)||
4214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4215 {
4216 4 return 0;
4217 }
4218
4219 110 word temp_door_combo_set_count=0;
4220 DoorComboSet tempDoorComboSet;
4221 word dummy_word;
4222 int32_t dummy_long;
4223 byte padding;
4224 110 int32_t s_version = 0;
4225
4226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(keepdata==true)
4227 {
4228
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 110 times.
28270 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4229 {
4230 28160 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4231 28160 }
4232 110 }
4233
4234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(Header->zelda_version > 0x192)
4235 {
4236 //section version info
4237
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
4238 {
4239 return qe_invalid;
4240 }
4241
4242 110 FFCore.quest_format[vDoors] = s_version;
4243
4244 //al_trace("Door combo sets version %d\n", dummy_word);
4245
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy_word,f,true))
4246 {
4247 return qe_invalid;
4248 }
4249
4250 //section size
4251
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy_long,f,true))
4252 {
4253 return qe_invalid;
4254 }
4255 110 }
4256
4257 //finally... section data
4258
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&temp_door_combo_set_count,f,true))
4259 {
4260 return qe_invalid;
4261 }
4262
4263
2/2
✓ Branch 0 taken 846 times.
✓ Branch 1 taken 110 times.
956 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4264 {
4265 846 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4266
4267 //name
4268
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4269 {
4270 return qe_invalid;
4271 }
4272
4273
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if(Header->zelda_version < 0x193)
4274 {
4275 if(!p_getc(&padding,f,true))
4276 {
4277 return qe_invalid;
4278 }
4279 }
4280
4281 //up door
4282
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4283 {
4284
2/2
✓ Branch 0 taken 30456 times.
✓ Branch 1 taken 7614 times.
38070 for(int32_t k=0; k<4; k++)
4285 {
4286
1/2
✓ Branch 0 taken 30456 times.
✗ Branch 1 not taken.
30456 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4287 {
4288 return qe_invalid;
4289 }
4290 30456 }
4291 7614 }
4292
4293
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4294 {
4295
2/2
✓ Branch 0 taken 30456 times.
✓ Branch 1 taken 7614 times.
38070 for(int32_t k=0; k<4; k++)
4296 {
4297
1/2
✓ Branch 0 taken 30456 times.
✗ Branch 1 not taken.
30456 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4298 {
4299 return qe_invalid;
4300 }
4301 30456 }
4302 7614 }
4303
4304 //down door
4305
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4306 {
4307
2/2
✓ Branch 0 taken 30456 times.
✓ Branch 1 taken 7614 times.
38070 for(int32_t k=0; k<4; k++)
4308 {
4309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30456 times.
30456 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4310 {
4311 return qe_invalid;
4312 }
4313 30456 }
4314 7614 }
4315
4316
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4317 {
4318
2/2
✓ Branch 0 taken 30456 times.
✓ Branch 1 taken 7614 times.
38070 for(int32_t k=0; k<4; k++)
4319 {
4320
1/2
✓ Branch 0 taken 30456 times.
✗ Branch 1 not taken.
30456 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4321 {
4322 return qe_invalid;
4323 }
4324 30456 }
4325 7614 }
4326
4327 //left door
4328
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4329 {
4330
2/2
✓ Branch 0 taken 45684 times.
✓ Branch 1 taken 7614 times.
53298 for(int32_t k=0; k<6; k++)
4331 {
4332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45684 times.
45684 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4333 {
4334 return qe_invalid;
4335 }
4336 45684 }
4337 7614 }
4338
4339
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4340 {
4341
2/2
✓ Branch 0 taken 45684 times.
✓ Branch 1 taken 7614 times.
53298 for(int32_t k=0; k<6; k++)
4342 {
4343
1/2
✓ Branch 0 taken 45684 times.
✗ Branch 1 not taken.
45684 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4344 {
4345 return qe_invalid;
4346 }
4347 45684 }
4348 7614 }
4349
4350 //right door
4351
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4352 {
4353
2/2
✓ Branch 0 taken 45684 times.
✓ Branch 1 taken 7614 times.
53298 for(int32_t k=0; k<6; k++)
4354 {
4355
1/2
✓ Branch 0 taken 45684 times.
✗ Branch 1 not taken.
45684 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4356 {
4357 return qe_invalid;
4358 }
4359 45684 }
4360 7614 }
4361
4362
2/2
✓ Branch 0 taken 7614 times.
✓ Branch 1 taken 846 times.
8460 for(int32_t j=0; j<9; j++)
4363 {
4364
2/2
✓ Branch 0 taken 45684 times.
✓ Branch 1 taken 7614 times.
53298 for(int32_t k=0; k<6; k++)
4365 {
4366
1/2
✓ Branch 0 taken 45684 times.
✗ Branch 1 not taken.
45684 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4367 {
4368 return qe_invalid;
4369 }
4370 45684 }
4371 7614 }
4372
4373 //up bomb rubble
4374
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 846 times.
2538 for(int32_t j=0; j<2; j++)
4375 {
4376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4377 {
4378 return qe_invalid;
4379 }
4380 1692 }
4381
4382
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 846 times.
2538 for(int32_t j=0; j<2; j++)
4383 {
4384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4385 {
4386 return qe_invalid;
4387 }
4388 1692 }
4389
4390 //down bomb rubble
4391
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 846 times.
2538 for(int32_t j=0; j<2; j++)
4392 {
4393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4394 {
4395 return qe_invalid;
4396 }
4397 1692 }
4398
4399
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 846 times.
2538 for(int32_t j=0; j<2; j++)
4400 {
4401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4402 {
4403 return qe_invalid;
4404 }
4405 1692 }
4406
4407 //left bomb rubble
4408
2/2
✓ Branch 0 taken 2538 times.
✓ Branch 1 taken 846 times.
3384 for(int32_t j=0; j<3; j++)
4409 {
4410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2538 times.
2538 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4411 {
4412 return qe_invalid;
4413 }
4414 2538 }
4415
4416
2/2
✓ Branch 0 taken 2538 times.
✓ Branch 1 taken 846 times.
3384 for(int32_t j=0; j<3; j++)
4417 {
4418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2538 times.
2538 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4419 {
4420 return qe_invalid;
4421 }
4422 2538 }
4423
4424
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if(Header->zelda_version < 0x193)
4425 {
4426 if(!p_getc(&padding,f,true))
4427 {
4428 return qe_invalid;
4429 }
4430
4431 }
4432
4433 //right bomb rubble
4434
2/2
✓ Branch 0 taken 2538 times.
✓ Branch 1 taken 846 times.
3384 for(int32_t j=0; j<3; j++)
4435 {
4436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2538 times.
2538 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4437 {
4438 return qe_invalid;
4439 }
4440 2538 }
4441
4442
2/2
✓ Branch 0 taken 2538 times.
✓ Branch 1 taken 846 times.
3384 for(int32_t j=0; j<3; j++)
4443 {
4444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2538 times.
2538 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4445 {
4446 return qe_invalid;
4447 }
4448 2538 }
4449
4450
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if(Header->zelda_version < 0x193)
4451 {
4452 if(!p_getc(&padding,f,true))
4453 {
4454 return qe_invalid;
4455 }
4456 }
4457
4458 //walkthrough stuff
4459
2/2
✓ Branch 0 taken 3384 times.
✓ Branch 1 taken 846 times.
4230 for(int32_t j=0; j<4; j++)
4460 {
4461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3384 times.
3384 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4462 {
4463 return qe_invalid;
4464 }
4465 3384 }
4466
4467
2/2
✓ Branch 0 taken 3384 times.
✓ Branch 1 taken 846 times.
4230 for(int32_t j=0; j<4; j++)
4468 {
4469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3384 times.
3384 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4470 {
4471 return qe_invalid;
4472 }
4473 3384 }
4474
4475 //flags
4476
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 846 times.
2538 for(int32_t j=0; j<2; j++)
4477 {
4478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4479 {
4480 return qe_invalid;
4481 }
4482 1692 }
4483
4484
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if(Header->zelda_version < 0x193)
4485 {
4486 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4487 {
4488 return qe_invalid;
4489 }
4490 }
4491
4492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 846 times.
846 if(keepdata==true)
4493 {
4494 846 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4495 846 }
4496 846 }
4497
4498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(keepdata==true)
4499 {
4500 110 door_combo_set_count=temp_door_combo_set_count;
4501 110 }
4502
4503 110 return 0;
4504 114 }
4505
4506 int32_t count_dmaps()
4507 {
4508 int32_t i=MAXDMAPS-1;
4509 bool found=false;
4510
4511 while(i>=0 && !found)
4512 {
4513 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4514 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4515 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4516 found=true;
4517
4518 for(int32_t j=0; j<8; j++)
4519 {
4520 if(DMaps[i].grid[j]!=0)
4521
4522 found=true;
4523 }
4524
4525 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4526 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4527 found=true;
4528
4529 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4530 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4531 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4532 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4533 found=true;
4534
4535 if(!found)
4536 {
4537 i--;
4538 }
4539 }
4540
4541 return i+1;
4542 }
4543
4544
4545 int32_t count_shops(miscQdata *Misc)
4546 {
4547 int32_t i=255,j;
4548 bool found=false;
4549
4550 while(i>=0 && !found)
4551 {
4552 j=2;
4553
4554 while(j>=0 && !found)
4555 {
4556 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4557 {
4558 found=true;
4559 }
4560 else
4561 {
4562 j--;
4563 }
4564 }
4565
4566 if(Misc->shop[i].name[0]!=0)
4567 {
4568 found=true;
4569 }
4570
4571 if(!found)
4572 {
4573 i--;
4574 }
4575 }
4576
4577 return i+1;
4578 }
4579
4580 int32_t count_infos(miscQdata *Misc)
4581 {
4582 int32_t i=255,j;
4583 bool found=false;
4584
4585 while(i>=0 && !found)
4586 {
4587 j=2;
4588
4589 while(j>=0 && !found)
4590 {
4591 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4592 {
4593 found=true;
4594 }
4595 else
4596 {
4597 j--;
4598 }
4599 }
4600
4601 if(Misc->info[i].name[0]!=0)
4602 {
4603 found=true;
4604 }
4605
4606 if(!found)
4607 {
4608 i--;
4609 }
4610 }
4611
4612 return i+1;
4613 }
4614
4615 int32_t count_warprings(miscQdata *Misc)
4616 {
4617 int32_t i=15,j;
4618 bool found=false;
4619
4620 while(i>=0 && !found)
4621 {
4622 j=7;
4623
4624 while(j>=0 && !found)
4625 {
4626 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4627 {
4628 found=true;
4629 }
4630 else
4631 {
4632 j--;
4633 }
4634 }
4635
4636 if(!found)
4637 {
4638 i--;
4639 }
4640 }
4641
4642 return i+1;
4643 }
4644
4645 int32_t count_palcycles(miscQdata *Misc)
4646 {
4647 int32_t i=255,j;
4648 bool found=false;
4649
4650 while(i>=0 && !found)
4651 {
4652 j=2;
4653
4654 while(j>=0 && !found)
4655 {
4656 if(Misc->cycles[i][j].count!=0)
4657 {
4658 found=true;
4659 }
4660 else
4661 {
4662 j--;
4663 }
4664 }
4665
4666 if(!found)
4667 {
4668 i--;
4669 }
4670 }
4671
4672 return i+1;
4673 }
4674
4675 203362 void clear_screen(mapscr *temp_scr)
4676 {
4677 203362 temp_scr->zero_memory();
4678 203362 }
4679
4680 114 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4681 {
4682 114 word dmapstoread=0;
4683 dmap tempDMap;
4684
4685 int32_t dummy;
4686 114 word s_version=0, s_cversion=0;
4687 byte padding;
4688
4689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
4690 {
4691
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<max_dmaps; i++)
4692 {
4693 58368 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4694 58368 sprintf(DMaps[start_dmap+i].title," ");
4695 58368 sprintf(DMaps[start_dmap+i].intro," ");
4696 58368 DMaps[start_dmap+i].type |= dmCAVE;
4697 58368 }
4698 114 }
4699
4700
3/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 4 times.
114 if(!Header || Header->zelda_version > 0x192)
4701 {
4702 //section version info
4703
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
4704 {
4705 return qe_invalid;
4706 }
4707
4708 110 FFCore.quest_format[vDMaps] = s_version;
4709
4710 //al_trace("DMaps version %d\n", s_version);
4711
4712
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_cversion,f,true))
4713 {
4714 return qe_invalid;
4715 }
4716
4717 //section size
4718
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
4719 {
4720 return qe_invalid;
4721 }
4722
4723 //finally... section data
4724
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dmapstoread,f,true))
4725 {
4726 return qe_invalid;
4727 }
4728 110 }
4729 else
4730 {
4731
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4732 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4733 {
4734 4 dmapstoread=32;
4735 4 }
4736 else if(s_version <= 4)
4737 {
4738 dmapstoread=OLDMAXDMAPS;
4739 }
4740 else
4741 {
4742 dmapstoread=MAXDMAPS;
4743 }
4744 }
4745
4746
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
114 dmapstoread=zc_min(dmapstoread, max_dmaps);
4747
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
114 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4748
4749
2/2
✓ Branch 0 taken 55168 times.
✓ Branch 1 taken 114 times.
55282 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4750 {
4751 55168 memset(&tempDMap,0,sizeof(dmap));
4752 55168 sprintf(tempDMap.title," ");
4753 55168 sprintf(tempDMap.intro," ");
4754
4755
1/2
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
55168 if(!p_getc(&tempDMap.map,f,keepdata))
4756 {
4757 return qe_invalid;
4758 }
4759
4760
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 53760 times.
55168 if(s_version <= 4)
4761 {
4762 byte tempbyte;
4763
4764
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&tempbyte,f,keepdata))
4765 {
4766 return qe_invalid;
4767 }
4768
4769 1408 tempDMap.level=(word)tempbyte;
4770 1408 }
4771 else
4772 {
4773
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&tempDMap.level,f,keepdata))
4774 {
4775 return qe_invalid;
4776 }
4777 }
4778
4779
1/2
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
55168 if(!p_getc(&tempDMap.xoff,f,keepdata))
4780 {
4781 return qe_invalid;
4782 }
4783
4784
1/2
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
55168 if(!p_getc(&tempDMap.compass,f,keepdata))
4785 {
4786 return qe_invalid;
4787 }
4788
4789
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 1408 times.
55168 if(s_version > 8) // February 2009
4790 {
4791
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&tempDMap.color,f,true))
4792 {
4793 return qe_invalid;
4794 }
4795 53760 }
4796 else
4797 {
4798 byte tempbyte;
4799
4800
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&tempbyte,f,true))
4801 {
4802 return qe_invalid;
4803 }
4804
4805 1408 tempDMap.color = (word)tempbyte;
4806 }
4807
4808
1/2
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
55168 if(!p_getc(&tempDMap.midi,f,keepdata))
4809 {
4810 return qe_invalid;
4811 }
4812
4813
1/2
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
55168 if(!p_getc(&tempDMap.cont,f,keepdata))
4814 {
4815 return qe_invalid;
4816 }
4817
4818
1/2
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
55168 if(!p_getc(&tempDMap.type,f,keepdata))
4819 {
4820 return qe_invalid;
4821 }
4822
4823
4/4
✓ Branch 0 taken 703 times.
✓ Branch 1 taken 54465 times.
✓ Branch 2 taken 691 times.
✓ Branch 3 taken 12 times.
55871 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4824
1/2
✓ Branch 0 taken 703 times.
✗ Branch 1 not taken.
703 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4825 691 tempDMap.xoff = 0;
4826
4827
2/2
✓ Branch 0 taken 441344 times.
✓ Branch 1 taken 55168 times.
496512 for(int32_t j=0; j<8; j++)
4828 {
4829
1/2
✓ Branch 0 taken 441344 times.
✗ Branch 1 not taken.
441344 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4830 {
4831 return qe_invalid;
4832 }
4833 441344 }
4834
4835
4/8
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55040 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
55168 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4836 {
4837
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4838 {
4839 38 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4840 38 }
4841
4842
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4843 {
4844 4 tempDMap.cont-=tempDMap.xoff;
4845 4 tempDMap.compass-=tempDMap.xoff;
4846 4 }
4847
4848 //forgotten -DD
4849
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4850 {
4851 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4852 90 }
4853 128 }
4854 else
4855 {
4856
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4857 {
4858 return qe_invalid;
4859 }
4860
4861
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4862 {
4863 return qe_invalid;
4864 }
4865
4866
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4867 {
4868 return qe_invalid;
4869 }
4870
4871
3/8
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 55040 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
55040 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4872 {
4873 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4874 if(keepdata==true)
4875 {
4876 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4877 }
4878
4879 continue;
4880 }
4881
4882
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if(Header && (Header->zelda_version < 0x193))
4883 {
4884 if(!p_getc(&padding,f,keepdata))
4885 {
4886 return qe_invalid;
4887 }
4888 }
4889
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40192 times.
55040 if ( s_version >= 11 )
4890 {
4891
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4892 {
4893 return qe_invalid;
4894 }
4895 14848 }
4896 else
4897 {
4898
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4899 {
4900 return qe_invalid;
4901 }
4902 }
4903
4904
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4905 {
4906 return qe_invalid;
4907 }
4908
4909
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if(Header && (Header->zelda_version < 0x193))
4910 {
4911 if(!p_getc(&padding,f,keepdata))
4912 {
4913 return qe_invalid;
4914 }
4915 }
4916
4917
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40192 times.
55040 if ( s_version >= 11 )
4918 {
4919
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4920 {
4921 return qe_invalid;
4922 }
4923 14848 }
4924 else
4925 {
4926
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4927 {
4928 return qe_invalid;
4929 }
4930 }
4931
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4932 {
4933 return qe_invalid;
4934 }
4935
4936
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if(Header && (Header->zelda_version < 0x193))
4937 {
4938 if(!p_getc(&padding,f,keepdata))
4939 {
4940 return qe_invalid;
4941 }
4942 }
4943
4944
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40192 times.
55040 if ( s_version >= 11 )
4945 {
4946
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4947 {
4948 return qe_invalid;
4949 }
4950 14848 }
4951 else
4952 {
4953
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4954 {
4955 return qe_invalid;
4956 }
4957 }
4958
4959
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4960 {
4961 return qe_invalid;
4962 }
4963
4964
2/4
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55040 times.
✗ Branch 3 not taken.
55040 if(Header && (Header->zelda_version < 0x193))
4965 {
4966
4967 if(!p_getc(&padding,f,keepdata))
4968 {
4969 return qe_invalid;
4970 }
4971 }
4972
4973
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40192 times.
55040 if ( s_version >= 11 )
4974 {
4975
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4976 {
4977 return qe_invalid;
4978 }
4979 14848 }
4980 else
4981 {
4982
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
4983 {
4984 return qe_invalid;
4985 }
4986 }
4987
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
4988 {
4989 return qe_invalid;
4990 }
4991
4992
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
4993 {
4994 return qe_invalid;
4995 }
4996 }
4997
4998
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 53760 times.
55168 if(s_version>1)
4999 {
5000
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
5001 {
5002 return qe_invalid;
5003 }
5004
5005
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
5006 {
5007 return qe_invalid;
5008 }
5009
5010
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
5011 {
5012 return qe_invalid;
5013 }
5014 53760 }
5015
5016
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 53760 times.
55168 if(s_version>2)
5017 {
5018 byte di[32];
5019
5020
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!pfread(&di, 32, f, true)) return qe_invalid;
5021
5022
2/2
✓ Branch 0 taken 13762560 times.
✓ Branch 1 taken 53760 times.
13816320 for(int32_t j=0; j<MAXITEMS; j++)
5023 {
5024
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13762553 times.
13762560 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
5025 13762553 else tempDMap.disableditems[j]=0;
5026 13762560 }
5027 53760 }
5028
5029
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 1408 times.
55168 if(s_version >= 6)
5030 {
5031
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&tempDMap.flags,f,keepdata))
5032 {
5033 return qe_invalid;
5034 }
5035 53760 }
5036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1408 times.
1408 else if(s_version>3)
5037 {
5038 char temp;
5039
5040 if(!p_getc(&temp,f,keepdata))
5041 {
5042 return qe_invalid;
5043 }
5044
5045 tempDMap.flags = temp;
5046 }
5047
3/8
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 697 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1408 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
5048 {
5049 697 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
5050 697 }
5051 else
5052 711 tempDMap.flags=0;
5053
5054
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 1408 times.
55168 if(s_version<7)
5055 {
5056
3/4
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✓ Branch 2 taken 697 times.
✗ Branch 3 not taken.
1408 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
5057 697 tempDMap.flags|= dmfVIEWMAP;
5058 1408 }
5059
5060
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 1408 times.
55168 if(s_version<8)
5061 {
5062
4/4
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 609 times.
1408 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
5063 {
5064 609 tempDMap.type &= ~dmDNGN;
5065 609 tempDMap.type |= dmCAVE;
5066 609 }
5067
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 469 times.
799 else if((tempDMap.type&dmfTYPE)==dmCAVE)
5068 {
5069 469 tempDMap.flags |= dmfMINIMAPCOLORFIX;
5070 469 }
5071 1408 }
5072
5073
5/8
✓ Branch 0 taken 55168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 55040 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 55040 times.
✗ Branch 7 not taken.
55168 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5074 55040 && (Header->zelda_version < 0x193))
5075 {
5076 if(!p_getc(&padding,f,keepdata))
5077 {
5078 return qe_invalid;
5079 }
5080 }
5081
5082
2/2
✓ Branch 0 taken 40320 times.
✓ Branch 1 taken 14848 times.
55168 if(s_version >= 10)
5083 {
5084
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempDMap.sideview,f,keepdata))
5085 {
5086 return qe_invalid;
5087 }
5088 14848 }
5089
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40320 times.
55168 if(s_version < 10) tempDMap.sideview = 0;
5090
5091 //Dmap Scripts
5092
2/2
✓ Branch 0 taken 40320 times.
✓ Branch 1 taken 14848 times.
55168 if(s_version >= 12)
5093 {
5094
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&tempDMap.script,f,keepdata))
5095 {
5096 return qe_invalid;
5097 }
5098
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; q++ )
5099 {
5100
1/2
✓ Branch 0 taken 118784 times.
✗ Branch 1 not taken.
118784 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
5101 {
5102 return qe_invalid;
5103 }
5104 118784 }
5105 14848 }
5106
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40320 times.
55168 if ( s_version < 12 )
5107 {
5108 40320 tempDMap.script = 0;
5109
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for ( int32_t q = 0; q < 8; q++ )
5110 {
5111 322560 tempDMap.initD[q] = 0;
5112 322560 }
5113 40320 }
5114
5115
2/2
✓ Branch 0 taken 40320 times.
✓ Branch 1 taken 14848 times.
55168 if(s_version >= 13)
5116 {
5117
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; q++ )
5118 {
5119
2/2
✓ Branch 0 taken 7720960 times.
✓ Branch 1 taken 118784 times.
7839744 for ( int32_t w = 0; w < 65; w++ )
5120 {
5121
1/2
✓ Branch 0 taken 7720960 times.
✗ Branch 1 not taken.
7720960 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
5122 {
5123 return qe_invalid;
5124 }
5125 7720960 }
5126 118784 }
5127 14848 }
5128
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40320 times.
55168 if ( s_version < 13 )
5129 {
5130 40320 tempDMap.script = 0;
5131
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for ( int32_t q = 0; q < 8; q++ )
5132 {
5133
2/2
✓ Branch 0 taken 20966400 times.
✓ Branch 1 taken 322560 times.
21288960 for ( int32_t w = 0; w < 65; w++ )
5134 20966400 tempDMap.initD_label[q][w] = 0;
5135 322560 }
5136 40320 }
5137
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40320 times.
55168 if(s_version >= 14)
5138 {
5139
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
5140 {
5141 return qe_invalid;
5142 }
5143
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5144 {
5145 return qe_invalid;
5146 }
5147
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; ++q )
5148 {
5149
1/2
✓ Branch 0 taken 118784 times.
✗ Branch 1 not taken.
118784 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5150 {
5151 return qe_invalid;
5152 }
5153 118784 }
5154
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for(int32_t q = 0; q < 8; ++q)
5155 {
5156
2/2
✓ Branch 0 taken 7720960 times.
✓ Branch 1 taken 118784 times.
7839744 for ( int32_t w = 0; w < 65; ++w )
5157 {
5158
1/2
✓ Branch 0 taken 7720960 times.
✗ Branch 1 not taken.
7720960 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5159 {
5160 return qe_invalid;
5161 }
5162 7720960 }
5163 118784 }
5164 14848 }
5165 else
5166 {
5167 40320 tempDMap.active_sub_script = 0;
5168 40320 tempDMap.passive_sub_script = 0;
5169
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for(int32_t q = 0; q < 8; ++q)
5170 {
5171 322560 tempDMap.sub_initD[q] = 0;
5172
2/2
✓ Branch 0 taken 20966400 times.
✓ Branch 1 taken 322560 times.
21288960 for(int32_t w = 0; w < 65; ++w)
5173 20966400 tempDMap.sub_initD_label[q][w] = 0;
5174 322560 }
5175 }
5176
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40320 times.
55168 if(s_version >= 15)
5177 {
5178
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5179 {
5180 return qe_invalid;
5181 }
5182
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; ++q )
5183 {
5184
1/2
✓ Branch 0 taken 118784 times.
✗ Branch 1 not taken.
118784 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5185 {
5186 return qe_invalid;
5187 }
5188 118784 }
5189
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for(int32_t q = 0; q < 8; ++q)
5190 {
5191
2/2
✓ Branch 0 taken 7720960 times.
✓ Branch 1 taken 118784 times.
7839744 for ( int32_t w = 0; w < 65; ++w )
5192 {
5193
1/2
✓ Branch 0 taken 7720960 times.
✗ Branch 1 not taken.
7720960 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5194 {
5195 return qe_invalid;
5196 }
5197 7720960 }
5198 118784 }
5199 14848 }
5200 else
5201 {
5202 40320 tempDMap.onmap_script = 0;
5203
2/2
✓ Branch 0 taken 322560 times.
✓ Branch 1 taken 40320 times.
362880 for(int32_t q = 0; q < 8; ++q)
5204 {
5205 322560 tempDMap.onmap_initD[q] = 0;
5206
2/2
✓ Branch 0 taken 20966400 times.
✓ Branch 1 taken 322560 times.
21288960 for(int32_t w = 0; w < 65; ++w)
5207 {
5208 20966400 tempDMap.onmap_initD_label[q][w] = 0;
5209 20966400 }
5210 322560 }
5211 }
5212
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 40320 times.
55168 if(s_version >= 16)
5213 {
5214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5215 {
5216 return qe_invalid;
5217 }
5218 14848 }
5219 else
5220 {
5221 40320 tempDMap.mirrorDMap = -1;
5222 }
5223
5224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55168 times.
55168 if(keepdata==true)
5225 {
5226 55168 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5227 55168 }
5228 55168 }
5229
5230 114 return 0;
5231 114 }
5232
5233 105 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5234 {
5235 //these are here to bypass compiler warnings about unused arguments
5236 105 Header=Header;
5237
5238 miscQdata temp_misc;
5239 105 word s_version=0, s_cversion=0;
5240 105 int32_t tempsize=0;
5241 word dummyw;
5242
5243 105 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5244
5245 //section version info
5246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
5247 {
5248 return qe_invalid;
5249 }
5250
5251 105 FFCore.quest_format[vColours] = s_version;
5252
5253 105 al_trace("Misc Colours section version: %d\n", s_version);
5254
5255 //al_trace("Misc. colors version %d\n", s_version);
5256
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
5257 {
5258 return qe_invalid;
5259 }
5260
5261
5262 //section size
5263
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&tempsize,f,true))
5264 {
5265 return qe_invalid;
5266 }
5267
5268 //finally... section data
5269 105 readsize=0;
5270
5271
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.text,f,true))
5272 {
5273 return qe_invalid;
5274 }
5275
5276
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.caption,f,true))
5277 {
5278 return qe_invalid;
5279 }
5280
5281
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5282 {
5283 return qe_invalid;
5284 }
5285
5286
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5287 {
5288 return qe_invalid;
5289 }
5290
5291
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5292 {
5293 return qe_invalid;
5294 }
5295
5296
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5297 {
5298 return qe_invalid;
5299 }
5300
5301
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5302 {
5303 return qe_invalid;
5304 }
5305
5306
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5307 {
5308 return qe_invalid;
5309 }
5310
5311
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5312 {
5313 return qe_invalid;
5314 }
5315
5316
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5317 {
5318 return qe_invalid;
5319 }
5320
5321
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5322 {
5323 return qe_invalid;
5324 }
5325
5326
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5327 {
5328 return qe_invalid;
5329 }
5330
5331
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5332 {
5333 return qe_invalid;
5334 }
5335
5336
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5337 {
5338 return qe_invalid;
5339 }
5340
5341
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5342 {
5343 return qe_invalid;
5344 }
5345
5346
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5347 {
5348 return qe_invalid;
5349 }
5350
5351
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5352 {
5353 return qe_invalid;
5354 }
5355
5356
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5357 {
5358 return qe_invalid;
5359 }
5360
5361
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5362 {
5363 return qe_invalid;
5364 }
5365
5366
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5367 {
5368 return qe_invalid;
5369 }
5370
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if(s_version < 4)
5371 {
5372
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5373 return qe_invalid;
5374 76 temp_misc.colors.triforce_tile = dummyw;
5375
5376
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5377 return qe_invalid;
5378 76 temp_misc.colors.triframe_tile = dummyw;
5379
5380
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5381 return qe_invalid;
5382 76 temp_misc.colors.overworld_map_tile = dummyw;
5383
5384
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5385 return qe_invalid;
5386 76 temp_misc.colors.dungeon_map_tile = dummyw;
5387
5388
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5389 return qe_invalid;
5390 76 temp_misc.colors.blueframe_tile = dummyw;
5391
5392
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&dummyw,f,true))
5393 return qe_invalid;
5394 76 temp_misc.colors.HCpieces_tile = dummyw;
5395 76 }
5396
5397
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5398 {
5399 return qe_invalid;
5400 }
5401
5402
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5403 {
5404 return qe_invalid;
5405 }
5406
5407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version < 2)
5408 {
5409 temp_misc.colors.msgtext = 0x01;
5410 }
5411 else
5412 {
5413
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5414 {
5415 return qe_invalid;
5416 }
5417 }
5418
5419
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if ( s_version >= 3 ) //expanded tile pages to 825
5420 {
5421
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5422 {
5423 return qe_invalid;
5424 }
5425
5426
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5427 {
5428 return qe_invalid;
5429 }
5430
5431
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5432 {
5433 return qe_invalid;
5434 }
5435
5436
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5437 {
5438 return qe_invalid;
5439 }
5440
5441
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5442 {
5443 return qe_invalid;
5444 }
5445
5446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5447 {
5448 return qe_invalid;
5449 }
5450 29 }
5451
5452
5453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata==true)
5454 {
5455 105 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5456 105 }
5457
5458 105 return 0;
5459 105 }
5460
5461 105 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5462 {
5463 miscQdata temp_misc;
5464 105 word s_version=0, s_cversion=0;
5465 byte icons;
5466 105 int32_t tempsize=0;
5467
5468 105 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5469
5470 //section version info
5471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
5472 {
5473 return qe_invalid;
5474 }
5475
5476 105 FFCore.quest_format[vIcons] = s_version;
5477
5478 //al_trace("Game icons version %d\n", s_version);
5479
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
5480 {
5481 return qe_invalid;
5482 }
5483
5484
5485 //section size
5486
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&tempsize,f,true))
5487 {
5488 return qe_invalid;
5489 }
5490
5491 //finally... section data
5492 105 readsize=0;
5493
5494 105 icons=4;
5495
5496
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if ( s_version >= 10 )
5497 {
5498
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<icons; i++)
5499 {
5500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_igetl(&temp_misc.icons[i],f,true))
5501 {
5502 return qe_invalid;
5503 }
5504 116 }
5505 29 }
5506 else
5507 {
5508
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<icons; i++)
5509 {
5510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(!p_igetw(&temp_misc.icons[i],f,true))
5511 {
5512 return qe_invalid;
5513 }
5514 304 }
5515 }
5516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata==true)
5517 {
5518 105 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5519 105 }
5520
5521 105 return 0;
5522 105 }
5523
5524 114 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5525 {
5526 114 word maxinfos=256;
5527 114 word maxshops=256;
5528 114 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5529 114 word ponds=16, pondsize=72, expansionsize=98*2;
5530 byte tempbyte, padding;
5531 miscQdata temp_misc;
5532 114 word s_version=0, s_cversion=0;
5533 word swaptmp;
5534 114 int32_t tempsize=0;
5535
5536 114 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5537
5538
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<maxshops; ++i)
5539 {
5540 29184 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5541 29184 }
5542
5543
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<maxinfos; ++i)
5544 {
5545 29184 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5546 29184 }
5547
5548
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version > 0x192)
5549 {
5550 //section version info
5551
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
5552 {
5553 return qe_invalid;
5554 }
5555
5556 110 FFCore.quest_format[vMisc] = s_version;
5557
5558 //al_trace("Misc. data version %d\n", s_version);
5559
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_cversion,f,true))
5560 {
5561 return qe_invalid;
5562 }
5563
5564
5565 //section size
5566
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&tempsize,f,true))
5567 {
5568 return qe_invalid;
5569 }
5570 110 }
5571
5572 //finally... section data
5573 114 readsize=0;
5574
5575 //shops
5576
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version > 0x192)
5577 {
5578
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&shops,f,true))
5579 {
5580 return qe_invalid;
5581 }
5582 110 }
5583
5584
2/2
✓ Branch 0 taken 1223 times.
✓ Branch 1 taken 114 times.
1337 for(int32_t i=0; i<shops; i++)
5585 {
5586
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1105 times.
1223 if(s_version > 6)
5587 {
5588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1105 times.
1105 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5589 {
5590 return qe_invalid;
5591 }
5592 1105 }
5593
5594
2/2
✓ Branch 0 taken 3669 times.
✓ Branch 1 taken 1223 times.
4892 for(int32_t j=0; j<3; j++)
5595 {
5596
1/2
✓ Branch 0 taken 3669 times.
✗ Branch 1 not taken.
3669 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5597 {
5598 return qe_invalid;
5599 }
5600
5601
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 354 times.
3669 if(s_version < 4)
5602 {
5603 354 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5604 354 }
5605 3669 }
5606
5607
2/2
✓ Branch 0 taken 1159 times.
✓ Branch 1 taken 64 times.
1223 if(Header->zelda_version < 0x193)
5608 {
5609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f,true))
5610 {
5611 return qe_invalid;
5612 }
5613 64 }
5614
5615
2/2
✓ Branch 0 taken 3669 times.
✓ Branch 1 taken 1223 times.
4892 for(int32_t j=0; j<3; j++)
5616 {
5617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3669 times.
3669 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5618 {
5619 return qe_invalid;
5620 }
5621 3669 }
5622
5623
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1105 times.
1223 if(s_version > 3)
5624 {
5625
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 1105 times.
4420 for(int32_t j=0; j<3; j++)
5626 {
5627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3315 times.
3315 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5628 return qe_invalid;
5629 3315 }
5630 1105 }
5631
5632 /*
5633 if(s_version < 8)
5634 {
5635 for(int32_t j=0; j<3; j++)
5636 {
5637 (&temp_misc.shop[i].str[j])=0; //initialise.
5638 }
5639 }
5640 */
5641 1223 }
5642
5643 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5644
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<maxshops; ++i)
5645 {
5646
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 29184 times.
87552 for(int32_t j=0; j<3-1; j++)
5647 {
5648
2/2
✓ Branch 0 taken 87552 times.
✓ Branch 1 taken 58368 times.
145920 for(int32_t k=0; k<2-j; k++)
5649 {
5650
2/2
✓ Branch 0 taken 2516 times.
✓ Branch 1 taken 85036 times.
87552 if(temp_misc.shop[i].hasitem[k]==0)
5651 {
5652 85036 swaptmp = temp_misc.shop[i].item[k];
5653 85036 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5654 85036 temp_misc.shop[i].item[k+1] = swaptmp;
5655 85036 swaptmp = temp_misc.shop[i].price[k];
5656 85036 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5657 85036 temp_misc.shop[i].price[k+1] = swaptmp;
5658 85036 swaptmp = temp_misc.shop[i].hasitem[k];
5659 85036 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5660 85036 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5661 85036 }
5662 87552 }
5663 58368 }
5664 29184 }
5665
5666 //infos
5667
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version > 0x192)
5668 {
5669
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&infos,f,true))
5670 {
5671 return qe_invalid;
5672 }
5673 110 }
5674
5675
2/2
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 114 times.
1732 for(int32_t i=0; i<infos; i++)
5676 {
5677
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 1539 times.
1618 if(s_version > 6)
5678 {
5679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1539 times.
1539 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5680 {
5681 return qe_invalid;
5682 }
5683 1539 }
5684
5685
2/2
✓ Branch 0 taken 4854 times.
✓ Branch 1 taken 1618 times.
6472 for(int32_t j=0; j<3; j++)
5686 {
5687
2/4
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4854 if((Header->zelda_version < 0x192)||
5688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4662 times.
4662 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5689 {
5690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f,true))
5691 {
5692 return qe_invalid;
5693 }
5694
5695 192 temp_misc.info[i].str[j]=tempbyte;
5696 192 }
5697 else
5698 {
5699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4662 times.
4662 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5700 {
5701 return qe_invalid;
5702 }
5703 }
5704 4854 }
5705
5706
2/2
✓ Branch 0 taken 1554 times.
✓ Branch 1 taken 64 times.
1618 if(Header->zelda_version < 0x193)
5707 {
5708
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f,true))
5709 {
5710 return qe_invalid;
5711 }
5712 64 }
5713
5714
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1618 if((Header->zelda_version == 0x192)&&(Header->build>145))
5715 {
5716 if(!p_getc(&padding,f,true))
5717 {
5718 return qe_invalid;
5719 }
5720 }
5721
5722
2/2
✓ Branch 0 taken 4854 times.
✓ Branch 1 taken 1618 times.
6472 for(int32_t j=0; j<3; j++)
5723 {
5724
1/2
✓ Branch 0 taken 4854 times.
✗ Branch 1 not taken.
4854 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5725 {
5726 return qe_invalid;
5727 }
5728 4854 }
5729 1618 }
5730
5731 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5732
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<maxinfos; ++i)
5733 {
5734
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 29184 times.
87552 for(int32_t j=0; j<3-1; j++)
5735 {
5736
2/2
✓ Branch 0 taken 87552 times.
✓ Branch 1 taken 58368 times.
145920 for(int32_t k=0; k<2-j; k++)
5737 {
5738
2/2
✓ Branch 0 taken 1887 times.
✓ Branch 1 taken 85665 times.
87552 if(temp_misc.info[i].str[k]==0)
5739 {
5740 85665 swaptmp = temp_misc.info[i].str[k];
5741 85665 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5742 85665 temp_misc.info[i].str[k+1] = swaptmp;
5743 85665 swaptmp = temp_misc.info[i].price[k];
5744 85665 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5745 85665 temp_misc.info[i].price[k+1] = swaptmp;
5746 85665 }
5747 87552 }
5748 58368 }
5749 29184 }
5750
5751
5752 //warp rings
5753
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
114 if(s_version > 5)
5754 105 warprings++;
5755
5756
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version > 0x192)
5757 {
5758
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&warprings,f,true))
5759 {
5760 return qe_invalid;
5761 }
5762 110 }
5763
5764
2/2
✓ Branch 0 taken 1112 times.
✓ Branch 1 taken 114 times.
1226 for(int32_t i=0; i<warprings; i++)
5765 {
5766
2/2
✓ Branch 0 taken 9896 times.
✓ Branch 1 taken 1112 times.
11008 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5767 {
5768
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 9000 times.
9896 if(s_version <= 3)
5769 {
5770
1/2
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
896 if(!p_getc(&tempbyte,f,true))
5771 {
5772 return qe_invalid;
5773 }
5774
5775 896 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5776 896 }
5777 else
5778 {
5779
1/2
✓ Branch 0 taken 9000 times.
✗ Branch 1 not taken.
9000 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,true))
5780 {
5781 return qe_invalid;
5782 }
5783 }
5784 9896 }
5785
5786
2/2
✓ Branch 0 taken 9896 times.
✓ Branch 1 taken 1112 times.
11008 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5787 {
5788
1/2
✓ Branch 0 taken 9896 times.
✗ Branch 1 not taken.
9896 if(!p_getc(&temp_misc.warp[i].scr[j],f,true))
5789 {
5790 return qe_invalid;
5791 }
5792 9896 }
5793
5794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1112 times.
1112 if(!p_getc(&temp_misc.warp[i].size,f,true))
5795 {
5796 return qe_invalid;
5797 }
5798
5799
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 32 times.
1112 if(Header->zelda_version < 0x193)
5800 {
5801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f,true))
5802 {
5803 return qe_invalid;
5804 }
5805 32 }
5806 1112 }
5807
5808 //palette cycles
5809
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5810 {
5811
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5812 {
5813
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5814 {
5815 3072 temp_misc.cycles[i][j].first=0;
5816 3072 temp_misc.cycles[i][j].count=0;
5817 3072 temp_misc.cycles[i][j].speed=0;
5818 3072 }
5819 1024 }
5820
5821
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5822 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5823 {
5824 4 palcycles=16;
5825 4 }
5826
5827
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5828 {
5829
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5830 {
5831
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5832 {
5833 return qe_invalid;
5834 }
5835
5836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5837 {
5838 return qe_invalid;
5839 }
5840
5841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5842 {
5843 return qe_invalid;
5844 }
5845 192 }
5846 64 }
5847 4 }
5848
5849 //Wind warps are now just another warp ring.
5850
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version <= 5)
5851 {
5852
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 if(Header->zelda_version > 0x192)
5853 {
5854
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&windwarps,f,true))
5855 {
5856 return qe_invalid;
5857 }
5858 5 }
5859
5860
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 9 times.
88 for(int32_t i=0; i<windwarps; i++)
5861 {
5862
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(s_version <= 3)
5863 {
5864
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&tempbyte,f,true))
5865 {
5866 return qe_invalid;
5867 }
5868
5869 79 temp_misc.warp[8].dmap[i]=tempbyte;
5870 79 }
5871 else
5872 {
5873 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5874 {
5875 return qe_invalid;
5876 }
5877 }
5878
5879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5880 {
5881 return qe_invalid;
5882 }
5883
5884 79 temp_misc.warp[8].size = 9;
5885
5886
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(s_version == 5)
5887 {
5888 if(!p_getc(&tempbyte,f,true))
5889 {
5890 return qe_invalid;
5891 }
5892 }
5893 79 }
5894 9 }
5895
5896
5897 //triforce pieces
5898
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 114 times.
1026 for(int32_t i=0; i<triforces; i++)
5899 {
5900
1/2
✓ Branch 0 taken 912 times.
✗ Branch 1 not taken.
912 if(!p_getc(&temp_misc.triforce[i],f,true))
5901 {
5902 return qe_invalid;
5903 }
5904 912 }
5905
5906 //misc color data
5907
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<3)
5908 {
5909
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.text,f,true))
5910 {
5911 return qe_invalid;
5912 }
5913
5914
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.caption,f,true))
5915 {
5916 return qe_invalid;
5917 }
5918
5919
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5920 {
5921 return qe_invalid;
5922 }
5923
5924
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5925 {
5926 return qe_invalid;
5927 }
5928
5929
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5930 {
5931 return qe_invalid;
5932 }
5933
5934
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5935 {
5936 return qe_invalid;
5937 }
5938
5939
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5940 {
5941 return qe_invalid;
5942 }
5943
5944
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5945 {
5946 return qe_invalid;
5947 }
5948
5949
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5950 {
5951 return qe_invalid;
5952 }
5953
5954
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5955 {
5956 return qe_invalid;
5957 }
5958
5959
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5960 {
5961 return qe_invalid;
5962 }
5963
5964
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5965 {
5966 return qe_invalid;
5967 }
5968
5969
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5970 {
5971 return qe_invalid;
5972 }
5973
5974
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5975 {
5976 return qe_invalid;
5977 }
5978
5979
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5980 {
5981 return qe_invalid;
5982 }
5983
5984
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5985 {
5986 return qe_invalid;
5987 }
5988
5989
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5990 {
5991 return qe_invalid;
5992 }
5993
5994
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5995 {
5996 return qe_invalid;
5997 }
5998
5999
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
6000 {
6001 return qe_invalid;
6002 }
6003
6004
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
6005 {
6006 return qe_invalid;
6007 }
6008
6009
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
6010 {
6011 return qe_invalid;
6012 }
6013
6014
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
6015 {
6016 return qe_invalid;
6017 }
6018
6019
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
6020 {
6021 return qe_invalid;
6022 }
6023
6024
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
6025 {
6026 return qe_invalid;
6027 }
6028
6029
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
6030 {
6031 return qe_invalid;
6032 }
6033
6034
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
6035 {
6036 return qe_invalid;
6037 }
6038
6039
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
6040 {
6041 return qe_invalid;
6042 }
6043
6044 9 temp_misc.colors.msgtext = 0x01;
6045
6046
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 if(Header->zelda_version < 0x193)
6047 {
6048
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6049 {
6050
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f,true))
6051 {
6052 return qe_invalid;
6053 }
6054 28 }
6055 4 }
6056
6057
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if((Header->zelda_version == 0x192)&&(Header->build>145))
6058 {
6059 for(int32_t i=0; i<256; i++)
6060 {
6061 if(!p_getc(&tempbyte,f,true))
6062 {
6063 return qe_invalid;
6064 }
6065 }
6066 }
6067
6068
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(s_version>1)
6069 {
6070 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
6071 {
6072 return qe_invalid;
6073 }
6074 }
6075
6076 //save game icons
6077
2/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if((Header->zelda_version < 0x192)||
6078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6079 {
6080 4 icons=3;
6081 4 }
6082
6083
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 9 times.
41 for(int32_t i=0; i<icons; i++)
6084 {
6085
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetw(&temp_misc.icons[i],f,true))
6086 {
6087 return qe_invalid;
6088 }
6089 32 }
6090 9 }
6091
6092
2/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if((Header->zelda_version < 0x192)||
6093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6094 {
6095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
6096 {
6097 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6098 4 }
6099
6100 4 return 0;
6101 }
6102
6103 //pond information
6104
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(Header->zelda_version < 0x193)
6105 {
6106 if((Header->zelda_version == 0x192)&&(Header->build<146))
6107 {
6108 pondsize=25;
6109 }
6110
6111 for(int32_t i=0; i<ponds; i++)
6112 {
6113 for(int32_t j=0; j<pondsize; j++)
6114 {
6115 if(!p_getc(&tempbyte,f,true))
6116 {
6117 return qe_invalid;
6118
6119 }
6120 }
6121 }
6122 }
6123
6124 //end string
6125
1/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110 if((Header->zelda_version < 0x192)||
6126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6127 {
6128 if(!p_getc(&tempbyte,f,true))
6129 {
6130 return qe_invalid;
6131 }
6132
6133 temp_misc.endstring=tempbyte;
6134
6135 if(!p_getc(&tempbyte,f,true))
6136 {
6137 return qe_invalid;
6138 }
6139 }
6140 else
6141 {
6142
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&temp_misc.endstring,f,true))
6143 {
6144 return qe_invalid;
6145 }
6146 }
6147
6148 //expansion
6149
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(Header->zelda_version < 0x193)
6150 {
6151 if((Header->zelda_version == 0x192)&&(Header->build<73))
6152 {
6153 expansionsize=99*2;
6154 }
6155
6156 for(int32_t i=0; i<expansionsize; i++)
6157 {
6158 if(!p_getc(&tempbyte,f,true))
6159 {
6160 return qe_invalid;
6161 }
6162 }
6163 }
6164 //shops v8
6165
6166
6167
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if(s_version >= 8)
6168 {
6169
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 29 times.
445 for(int32_t i=0; i<shops; i++)
6170 {
6171
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 416 times.
1664 for(int32_t j=0; j<3; j++)
6172 {
6173
1/2
✓ Branch 0 taken 1248 times.
✗ Branch 1 not taken.
1248 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6174 return qe_invalid;
6175 1248 }
6176 416 }
6177 29 }
6178
6179 110 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6180 110 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6181 110 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6182
6183 //v9 includes quest misc[32]
6184
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if(s_version >= 9)
6185 {
6186
2/2
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 29 times.
957 for ( int32_t q = 0; q < 32; q++ )
6187 {
6188
1/2
✓ Branch 0 taken 928 times.
✗ Branch 1 not taken.
928 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6189 return qe_invalid;
6190 928 }
6191
2/2
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 29 times.
957 for ( int32_t q = 0; q < 32; q++ )
6192 {
6193
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 928 times.
119712 for ( int32_t j = 0; j < 128; j++ )
6194
1/2
✓ Branch 0 taken 118784 times.
✗ Branch 1 not taken.
118784 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6195 return qe_invalid;
6196 928 }
6197 29 }
6198
6199
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(s_version >= 11 )
6200 {
6201
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6202 return qe_invalid;
6203 29 }
6204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 else if(s_version < 11 )
6205 {
6206 81 temp_misc.zscript_last_compiled_version = -1;
6207 81 }
6208
6209 110 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6210
6211
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(s_version >= 12)
6212 {
6213 byte spr;
6214
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t q = 0; q < sprMAX; ++q)
6215 {
6216
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_getc(&spr,f,true))
6217 return qe_invalid;
6218 7424 temp_misc.sprites[q] = spr;
6219 7424 }
6220 29 }
6221 else
6222 {
6223 81 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6224 //temp_misc.sprites[sprFALL] = ;
6225 }
6226
6227
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(s_version >= 13)
6228 {
6229
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 29 times.
1885 for(size_t q = 0; q < 64; ++q)
6230 {
6231 1856 bottletype* bt = &(temp_misc.bottle_types[q]);
6232
1/2
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
1856 if (!pfread(bt->name, 32, f, true))
6233 return qe_invalid;
6234
2/2
✓ Branch 0 taken 5568 times.
✓ Branch 1 taken 1856 times.
7424 for(size_t j = 0; j < 3; ++j)
6235 {
6236
1/2
✓ Branch 0 taken 5568 times.
✗ Branch 1 not taken.
5568 if (!p_getc(&(bt->counter[j]), f, true))
6237 return qe_invalid;
6238
1/2
✓ Branch 0 taken 5568 times.
✗ Branch 1 not taken.
5568 if (!p_igetw(&(bt->amount[j]), f, true))
6239 return qe_invalid;
6240 5568 }
6241
1/2
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
1856 if (!p_getc(&(bt->flags), f, true))
6242 return qe_invalid;
6243
1/2
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
1856 if (!p_getc(&(bt->next_type), f, true))
6244 return qe_invalid;
6245 1856 }
6246
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(size_t q = 0; q < 256; ++q)
6247 {
6248 7424 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6249
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if (!pfread(bst->name, 32, f, true))
6250 return qe_invalid;
6251
2/2
✓ Branch 0 taken 22272 times.
✓ Branch 1 taken 7424 times.
29696 for(size_t j = 0; j < 3; ++j)
6252 {
6253
1/2
✓ Branch 0 taken 22272 times.
✗ Branch 1 not taken.
22272 if (!p_getc(&(bst->fill[j]), f, true))
6254 return qe_invalid;
6255
1/2
✓ Branch 0 taken 22272 times.
✗ Branch 1 not taken.
22272 if (!p_igetw(&(bst->comb[j]), f, true))
6256 return qe_invalid;
6257
1/2
✓ Branch 0 taken 22272 times.
✗ Branch 1 not taken.
22272 if (!p_getc(&(bst->cset[j]), f, true))
6258 return qe_invalid;
6259
1/2
✓ Branch 0 taken 22272 times.
✗ Branch 1 not taken.
22272 if (!p_igetw(&(bst->price[j]), f, true))
6260 return qe_invalid;
6261
1/2
✓ Branch 0 taken 22272 times.
✗ Branch 1 not taken.
22272 if (!p_igetw(&(bst->str[j]), f, true))
6262 return qe_invalid;
6263 22272 }
6264 7424 }
6265 29 }
6266 else
6267 {
6268
2/2
✓ Branch 0 taken 5184 times.
✓ Branch 1 taken 81 times.
5265 for(size_t q = 0; q < 64; ++q)
6269 5184 temp_misc.bottle_types[q].clear();
6270
2/2
✓ Branch 0 taken 20736 times.
✓ Branch 1 taken 81 times.
20817 for(size_t q = 0; q < 256; ++q)
6271 20736 temp_misc.bottle_shop_types[q].clear();
6272 }
6273
6274
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(s_version >= 14)
6275 {
6276 byte msfx;
6277
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t q = 0; q < sfxMAX; ++q)
6278 {
6279
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_getc(&msfx,f,true))
6280 return qe_invalid;
6281 7424 temp_misc.miscsfx[q] = msfx;
6282 7424 }
6283 29 }
6284 else
6285 {
6286 81 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6287 81 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6288 81 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6289 }
6290
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if(s_version < 15)
6291 {
6292 81 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6293 81 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6294 81 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6295 81 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6296 81 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6297 81 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6298 81 }
6299
6300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(keepdata==true)
6301 {
6302 110 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6303 110 }
6304
6305 110 return 0;
6306 114 }
6307
6308 extern char *item_string[ITEMCNT];
6309 extern const char *old_item_string[iLast];
6310 extern char *weapon_string[WPNCNT];
6311 extern const char *old_weapon_string[wLast];
6312
6313 114 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6314 {
6315 byte padding;
6316 int32_t dummy;
6317 114 word items_to_read=MAXITEMS;
6318 itemdata tempitem;
6319 114 word s_version=0, s_cversion=0;
6320 word dummy_word;
6321
6322
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(version < 0x186)
6323 {
6324 items_to_read=64;
6325 }
6326
6327
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(version > 0x192)
6328 {
6329 110 items_to_read=0;
6330
6331 //section version info
6332
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
6333 {
6334 return qe_invalid;
6335 }
6336
6337 110 FFCore.quest_format[vItems] = s_version;
6338
6339 //al_trace("Items version %d\n", s_version);
6340
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_cversion,f,true))
6341 {
6342 return qe_invalid;
6343 }
6344
6345 //section size
6346
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
6347 {
6348 return qe_invalid;
6349 }
6350
6351 //finally... section data
6352
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&items_to_read,f,true))
6353 {
6354 return qe_invalid;
6355 }
6356 110 }
6357
6358
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version>1)
6359 {
6360
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i=0; i<items_to_read; i++)
6361 {
6362 char tempname[64];
6363
6364
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!pfread(tempname, 64, f, keepdata))
6365 {
6366 return qe_invalid;
6367 }
6368
6369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(keepdata)
6370 {
6371 26880 strcpy(item_string[i], tempname);
6372 26880 }
6373 26880 }
6374 105 }
6375 else
6376 {
6377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
6378 {
6379
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<ITEMCNT; i++)
6380 {
6381 2304 reset_itemname(i);
6382 2304 }
6383 9 }
6384 }
6385
6386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata)
6387 {
6388
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<MAXITEMS; i++)
6389 {
6390 29184 itemdata& id = itemsbuf[i];
6391 29184 memset(&id, 0, sizeof(itemdata));
6392 29184 id.count=-1;
6393 29184 id.playsound=WAV_SCALE;
6394 29184 reset_itembuf(&id,i);
6395 29184 }
6396 114 }
6397
6398
2/2
✓ Branch 0 taken 28254 times.
✓ Branch 1 taken 114 times.
28368 for(int32_t i=0; i<items_to_read; i++)
6399 {
6400 28254 memset(&tempitem, 0, sizeof(itemdata));
6401 28254 reset_itembuf(&tempitem,i);
6402
6403
6404
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 20830 times.
28254 if ( s_version > 35 ) //expanded tiles
6405 {
6406
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.tile,f,true))
6407 {
6408 return qe_invalid;
6409 }
6410 7424 }
6411 else
6412 {
6413
1/2
✓ Branch 0 taken 20830 times.
✗ Branch 1 not taken.
20830 if(!p_igetw(&tempitem.tile,f,true))
6414 {
6415 return qe_invalid;
6416 }
6417 }
6418
6419
1/2
✓ Branch 0 taken 28254 times.
✗ Branch 1 not taken.
28254 if(!p_getc(&tempitem.misc_flags,f,true))
6420 {
6421 return qe_invalid;
6422 }
6423
6424
1/2
✓ Branch 0 taken 28254 times.
✗ Branch 1 not taken.
28254 if(!p_getc(&tempitem.csets,f,true))
6425 {
6426 return qe_invalid;
6427 }
6428
6429
1/2
✓ Branch 0 taken 28254 times.
✗ Branch 1 not taken.
28254 if(!p_getc(&tempitem.frames,f,true))
6430 {
6431 return qe_invalid;
6432 }
6433
6434
1/2
✓ Branch 0 taken 28254 times.
✗ Branch 1 not taken.
28254 if(!p_getc(&tempitem.speed,f,true))
6435 {
6436 return qe_invalid;
6437 }
6438
6439
1/2
✓ Branch 0 taken 28254 times.
✗ Branch 1 not taken.
28254 if(!p_getc(&tempitem.delay,f,true))
6440 {
6441 return qe_invalid;
6442 }
6443
6444
2/2
✓ Branch 0 taken 27230 times.
✓ Branch 1 taken 1024 times.
28254 if(version < 0x193)
6445 {
6446
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f,true))
6447 {
6448 return qe_invalid;
6449 }
6450
6451
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6452 {
6453
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6454 {
6455 case iShield:
6456 4 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6457 4 break;
6458
6459 case iMShield:
6460 4 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6461 4 break;
6462
6463 default:
6464 1016 tempitem.ltm=0;
6465 1016 break;
6466 }
6467
6468 1024 tempitem.count=-1;
6469 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6470 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6471 1024 tempitem.family=0xFF;
6472 1024 tempitem.playsound=WAV_SCALE;
6473 1024 reset_itembuf(&tempitem,i);
6474
6475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(keepdata==true)
6476 {
6477 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6478 1024 }
6479
6480 1024 continue;
6481 }
6482 }
6483
6484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27230 times.
27230 if(!p_igetl(&tempitem.ltm,f,true))
6485 {
6486 return qe_invalid;
6487 }
6488
6489
1/2
✓ Branch 0 taken 27230 times.
✗ Branch 1 not taken.
27230 if(version < 0x193)
6490 {
6491 for(int32_t q=0; q<12; q++)
6492 {
6493 if(!p_getc(&padding,f,true))
6494 {
6495 return qe_invalid;
6496 }
6497 }
6498 }
6499
6500
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 350 times.
27230 if(s_version>1)
6501 {
6502
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 19456 times.
26880 if ( s_version >= 31 )
6503 {
6504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.family,f,true))
6505 {
6506 return qe_invalid;
6507 }
6508 7424 }
6509 else
6510 {
6511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19456 times.
19456 if(!p_getc(&tempitem.family,f,true))
6512 {
6513 return qe_invalid;
6514 }
6515 }
6516
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(s_version < 16)
6517 if(tempitem.family == 0xFF)
6518 tempitem.family = itype_misc;
6519
6520
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.fam_type,f,true))
6521 {
6522 return qe_invalid;
6523 }
6524
6525
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(s_version>5)
6526 {
6527
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 19456 times.
26880 if(s_version>=31)
6528 {
6529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.power,f,true))
6530 {
6531 return qe_invalid;
6532 }
6533 7424 }
6534 else
6535 {
6536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19456 times.
19456 if(!p_getc(&tempitem.power,f,true))
6537 {
6538 return qe_invalid;
6539 }
6540 }
6541
6542 //converted flags from 16b to 32b -Z
6543
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version < 41 )
6544 {
6545
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetw(&tempitem.flags,f,true))
6546 {
6547 return qe_invalid;
6548 }
6549 19456 }
6550 else
6551 {
6552
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.flags,f,true))
6553 {
6554 return qe_invalid;
6555 }
6556 }
6557 26880 }
6558 else
6559 {
6560 //tempitem.power = tempitem.fam_type;
6561 char tempchar;
6562
6563 if(!p_getc(&tempchar,f,true))
6564 {
6565 return qe_invalid;
6566 }
6567
6568 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6569 }
6570
6571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetw(&tempitem.script,f,true))
6572 {
6573 return qe_invalid;
6574 }
6575
6576
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(s_version<=3)
6577 {
6578 if(tempitem.script > NUMSCRIPTITEM)
6579 {
6580 tempitem.script = 0;
6581 }
6582 }
6583
6584
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.count,f,true))
6585 {
6586 return qe_invalid;
6587 }
6588
6589
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetw(&tempitem.amount,f,true))
6590 {
6591 return qe_invalid;
6592 }
6593
6594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetw(&tempitem.collect_script,f,true))
6595 {
6596 return qe_invalid;
6597 }
6598
6599
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(s_version<=3)
6600 {
6601 if(tempitem.collect_script > NUMSCRIPTITEM)
6602 {
6603 tempitem.collect_script = 0;
6604 }
6605 }
6606
6607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetw(&tempitem.setmax,f,true))
6608 {
6609 return qe_invalid;
6610 }
6611
6612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetw(&tempitem.max,f,true))
6613 {
6614 return qe_invalid;
6615 }
6616
6617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_getc(&tempitem.playsound,f,true))
6618 {
6619 return qe_invalid;
6620 }
6621
6622
2/2
✓ Branch 0 taken 215040 times.
✓ Branch 1 taken 26880 times.
241920 for(int32_t j=0; j<8; j++)
6623 {
6624
1/2
✓ Branch 0 taken 215040 times.
✗ Branch 1 not taken.
215040 if(!p_igetl(&tempitem.initiald[j],f,true))
6625 {
6626 return qe_invalid;
6627 }
6628 215040 }
6629
6630
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 26880 times.
80640 for(int32_t j=0; j<2; j++)
6631 {
6632
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&tempitem.initiala[j],f,true))
6633 {
6634 return qe_invalid;
6635 }
6636 53760 }
6637
6638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(s_version>4)
6639 {
6640
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(s_version>5)
6641 {
6642
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn,f,true))
6643 {
6644 return qe_invalid;
6645 }
6646
6647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_getc(&tempitem.wpn2,f,true))
6648 {
6649 return qe_invalid;
6650 }
6651
6652
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn3,f,true))
6653 {
6654 return qe_invalid;
6655 }
6656
6657
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn4,f,true))
6658 {
6659 return qe_invalid;
6660 }
6661
6662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(s_version>=15)
6663 {
6664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_getc(&tempitem.wpn5,f,true))
6665 {
6666 return qe_invalid;
6667 }
6668
6669
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn6,f,true))
6670 {
6671 return qe_invalid;
6672 }
6673
6674
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn7,f,true))
6675 {
6676 return qe_invalid;
6677 }
6678
6679
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn8,f,true))
6680 {
6681 return qe_invalid;
6682 }
6683
6684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_getc(&tempitem.wpn9,f,true))
6685 {
6686 return qe_invalid;
6687 }
6688
6689
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.wpn10,f,true))
6690 {
6691 return qe_invalid;
6692 }
6693 26880 }
6694
6695
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.pickup_hearts,f,true))
6696 {
6697 return qe_invalid;
6698 }
6699
6700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(s_version<15)
6701 {
6702 if(!p_igetw(&dummy_word,f,true))
6703 {
6704 return qe_invalid;
6705 }
6706
6707 tempitem.misc1=dummy_word;
6708
6709 if(!p_igetw(&dummy_word,f,true))
6710 {
6711 return qe_invalid;
6712 }
6713
6714 tempitem.misc2=dummy_word;
6715 }
6716 else
6717 {
6718
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetl(&tempitem.misc1,f,true))
6719 {
6720 return qe_invalid;
6721 }
6722
6723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetl(&tempitem.misc2,f,true))
6724 {
6725 return qe_invalid;
6726 }
6727
6728 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6729
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(s_version<24)
6730 {
6731 if(tempitem.family==itype_shield)
6732 {
6733 tempitem.misc1|=shSCRIPT;
6734 }
6735 }
6736 }
6737
6738
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if(s_version < 53)
6739 {
6740 byte tempbyte;
6741
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_getc(&tempbyte,f,true))
6742 {
6743 return qe_invalid;
6744 }
6745 19456 tempitem.cost_amount[0] = tempbyte;
6746 19456 }
6747 else
6748 {
6749
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 7424 times.
22272 for(auto q = 0; q < 2; ++q)
6750 {
6751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6752 {
6753 return qe_invalid;
6754 }
6755 14848 }
6756 }
6757 26880 }
6758 else
6759 {
6760 char tempchar;
6761
6762 if(!p_getc(&tempchar,f,true))
6763 {
6764 return qe_invalid;
6765 }
6766
6767 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6768 }
6769
6770 // June 2007: more misc. attributes
6771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(s_version>=12)
6772 {
6773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(s_version<15)
6774 {
6775 if(!p_igetw(&dummy_word,f,true))
6776 {
6777 return qe_invalid;
6778 }
6779
6780 tempitem.misc3=dummy_word;
6781
6782 if(!p_igetw(&dummy_word,f,true))
6783 {
6784 return qe_invalid;
6785 }
6786
6787 tempitem.misc4=dummy_word;
6788 }
6789 else
6790 {
6791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetl(&tempitem.misc3,f,true))
6792 {
6793 return qe_invalid;
6794 }
6795
6796
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetl(&tempitem.misc4,f,true))
6797 {
6798 return qe_invalid;
6799 }
6800
6801
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetl(&tempitem.misc5,f,true))
6802 {
6803 return qe_invalid;
6804 }
6805
6806
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetl(&tempitem.misc6,f,true))
6807 {
6808 return qe_invalid;
6809 }
6810
6811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetl(&tempitem.misc7,f,true))
6812 {
6813 return qe_invalid;
6814 }
6815
6816
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetl(&tempitem.misc8,f,true))
6817 {
6818 return qe_invalid;
6819 }
6820
6821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(!p_igetl(&tempitem.misc9,f,true))
6822 {
6823 return qe_invalid;
6824 }
6825
6826
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_igetl(&tempitem.misc10,f,true))
6827 {
6828 return qe_invalid;
6829 }
6830 }
6831
6832
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!p_getc(&tempitem.usesound,f,true))
6833 {
6834 return qe_invalid;
6835 }
6836
6837
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 19456 times.
26880 if(s_version >= 49)
6838 {
6839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_getc(&tempitem.usesound2,f,true))
6840 {
6841 return qe_invalid;
6842 }
6843 7424 }
6844 19456 else tempitem.usesound2 = 0;
6845
6846
3/4
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
26880 if(s_version < 50 && tempitem.family == itype_mirror)
6847 {
6848 //Split continue/dmap warp effect/sfx, port for old
6849 tempitem.misc2 = tempitem.misc1;
6850 tempitem.usesound2 = tempitem.usesound;
6851 }
6852 26880 }
6853 26880 }
6854
6855
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6856 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_getc(&tempitem.useweapon,f,true))
6858 {
6859 return qe_invalid;
6860 }
6861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_getc(&tempitem.usedefence,f,true))
6862 {
6863 return qe_invalid;
6864 }
6865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weaprange,f,true))
6866 {
6867 return qe_invalid;
6868 }
6869
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.weapduration,f,true))
6870 {
6871 return qe_invalid;
6872 }
6873
2/2
✓ Branch 0 taken 74240 times.
✓ Branch 1 taken 7424 times.
81664 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6874 {
6875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74240 times.
74240 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6876 {
6877 return qe_invalid;
6878 }
6879 74240 }
6880 7424 }
6881
6882
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6883 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6884
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.duplicates,f,true))
6885 {
6886 return qe_invalid;
6887 }
6888
2/2
✓ Branch 0 taken 59392 times.
✓ Branch 1 taken 7424 times.
66816 for ( int32_t q = 0; q < INITIAL_D; q++ )
6889 {
6890
1/2
✓ Branch 0 taken 59392 times.
✗ Branch 1 not taken.
59392 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6891 {
6892 return qe_invalid;
6893 }
6894 59392 }
6895
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 7424 times.
22272 for ( int32_t q = 0; q < INITIAL_A; q++ )
6896 {
6897
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6898 {
6899 return qe_invalid;
6900 }
6901 14848 }
6902
6903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_getc(&tempitem.drawlayer,f,true))
6904 {
6905 return qe_invalid;
6906 }
6907
6908
6909
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.hxofs,f,true))
6910 {
6911 return qe_invalid;
6912 }
6913
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.hyofs,f,true))
6914 {
6915 return qe_invalid;
6916 }
6917
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.hxsz,f,true))
6918 {
6919 return qe_invalid;
6920 }
6921
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.hysz,f,true))
6922 {
6923 return qe_invalid;
6924 }
6925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.hzsz,f,true))
6926 {
6927 return qe_invalid;
6928 }
6929
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.xofs,f,true))
6930 {
6931 return qe_invalid;
6932 }
6933
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.yofs,f,true))
6934 {
6935 return qe_invalid;
6936 }
6937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6938 {
6939 return qe_invalid;
6940 }
6941
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6942 {
6943 return qe_invalid;
6944 }
6945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6946 {
6947 return qe_invalid;
6948 }
6949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weap_hysz,f,true))
6950 {
6951 return qe_invalid;
6952 }
6953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weap_hzsz,f,true))
6954 {
6955 return qe_invalid;
6956 }
6957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weap_xofs,f,true))
6958 {
6959 return qe_invalid;
6960 }
6961
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.weap_yofs,f,true))
6962 {
6963 return qe_invalid;
6964 }
6965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetw(&tempitem.weaponscript,f,true))
6966 {
6967 return qe_invalid;
6968 }
6969
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.wpnsprite,f,true))
6970 {
6971 return qe_invalid;
6972 }
6973 7424 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6974
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 7424 times.
22272 for(auto q = 0; q < num_cost_tmr; ++q)
6975 {
6976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
6977 {
6978 return qe_invalid;
6979 }
6980 14848 }
6981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 for(auto q = num_cost_tmr; q < 2; ++q)
6982 tempitem.magiccosttimer[q] = 0;
6983 7424 }
6984
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6985 {
6986 //Item Size FLags, TileWidth, TileHeight
6987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
6988 {
6989 return qe_invalid;
6990 }
6991
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.tilew,f,true))
6992 {
6993 return qe_invalid;
6994 }
6995
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.tileh,f,true))
6996 {
6997 return qe_invalid;
6998 }
6999 7424 }
7000
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 29 ) //! More new vars.
7001 {
7002 //Item Size FLags, TileWidth, TileHeight
7003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
7004 {
7005 return qe_invalid;
7006 }
7007
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.weap_tilew,f,true))
7008 {
7009 return qe_invalid;
7010 }
7011
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.weap_tileh,f,true))
7012 {
7013 return qe_invalid;
7014 }
7015 7424 }
7016
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 30 ) //! More new vars.
7017 {
7018 //Pickup Type
7019
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempitem.pickup,f,true))
7020 {
7021 return qe_invalid;
7022 }
7023 7424 }
7024
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 32 ) //! More new vars.
7025 {
7026 //Pickup Type
7027
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetw(&tempitem.pstring,f,true))
7028 {
7029 return qe_invalid;
7030 }
7031 7424 }
7032
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 33 ) //! More new vars.
7033 {
7034 //Pickup Type
7035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
7036 {
7037 return qe_invalid;
7038 }
7039 7424 }
7040
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 34 ) //! cost counter
7041 {
7042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7424 times.
7424 if(s_version < 53)
7043 {
7044 if(!p_getc(&tempitem.cost_counter[0],f,true))
7045 {
7046 return qe_invalid;
7047 }
7048 }
7049 else
7050 {
7051
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 7424 times.
22272 for(auto q = 0; q < 2; ++q)
7052 {
7053
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&tempitem.cost_counter[q],f,true))
7054 {
7055 return qe_invalid;
7056 }
7057 14848 }
7058 }
7059 7424 }
7060
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 44 ) //! sprite scripts
7061 {
7062
2/2
✓ Branch 0 taken 59392 times.
✓ Branch 1 taken 7424 times.
66816 for ( int32_t q = 0; q < 8; q++ )
7063 {
7064
2/2
✓ Branch 0 taken 3860480 times.
✓ Branch 1 taken 59392 times.
3919872 for ( int32_t w = 0; w < 65; w++ )
7065 {
7066
1/2
✓ Branch 0 taken 3860480 times.
✗ Branch 1 not taken.
3860480 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
7067 {
7068 return qe_invalid;
7069 }
7070 3860480 }
7071
2/2
✓ Branch 0 taken 3860480 times.
✓ Branch 1 taken 59392 times.
3919872 for ( int32_t w = 0; w < 65; w++ )
7072 {
7073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3860480 times.
3860480 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
7074 {
7075 return qe_invalid;
7076 }
7077 3860480 }
7078
2/2
✓ Branch 0 taken 3860480 times.
✓ Branch 1 taken 59392 times.
3919872 for ( int32_t w = 0; w < 65; w++ )
7079 {
7080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3860480 times.
3860480 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
7081 {
7082 return qe_invalid;
7083 }
7084 3860480 }
7085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59392 times.
59392 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
7086 {
7087 return qe_invalid;
7088 }
7089
7090 59392 }
7091
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 7424 times.
22272 for ( int32_t q = 0; q < 2; q++ )
7092 {
7093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
7094 {
7095 return qe_invalid;
7096 }
7097 14848 }
7098 //Pickup Type
7099
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetw(&tempitem.sprite_script,f,true))
7100 {
7101 return qe_invalid;
7102 }
7103 7424 }
7104
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 7424 times.
26880 if ( s_version >= 48 ) //! pickup flags
7105 {
7106
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
7107 {
7108 return qe_invalid;
7109 }
7110 7424 }
7111
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 5888 times.
26880 if ( s_version >= 57 )
7112 {
7113 5888 std::string str;
7114
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
✓ Branch 2 taken 5888 times.
✗ Branch 3 not taken.
5888 if(!p_getcstr(&str,f,true))
7115 return qe_invalid;
7116 5888 strncpy(tempitem.display_name,str.c_str(),255);
7117
1/3
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5888 }
7118 26880 }
7119 else
7120 {
7121 350 tempitem.count=-1;
7122 350 tempitem.family=itype_misc;
7123 350 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7124 350 tempitem.playsound=WAV_SCALE;
7125 350 reset_itembuf(&tempitem,i);
7126 }
7127
7128
1/2
✓ Branch 0 taken 27230 times.
✗ Branch 1 not taken.
27230 if(keepdata==true)
7129 {
7130 27230 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7131 27230 }
7132 else if(zgpmode)
7133 {
7134 itemsbuf[i].tile=tempitem.tile;
7135 itemsbuf[i].misc_flags=tempitem.misc_flags;
7136 itemsbuf[i].csets=tempitem.csets;
7137 itemsbuf[i].frames=tempitem.frames;
7138 itemsbuf[i].speed=tempitem.speed;
7139 itemsbuf[i].delay=tempitem.delay;
7140 itemsbuf[i].ltm=tempitem.ltm;
7141 }
7142 27230 }
7143
7144 //////////////////////////////////////////////////////
7145 // Now do any updates because of new item additions
7146 // (These can't be done above because items_to_read
7147 // might be too low.)
7148 //////////////////////////////////////////////////////
7149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
7150 {
7151
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<MAXITEMS; i++)
7152 {
7153 29184 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7154
7155 //Account for older quests that didn't have an actual item for the used letter
7156
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 26880 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
29184 if(s_version < 2 && i==iLetterUsed)
7157 {
7158 9 reset_itembuf(&tempitem, iLetterUsed);
7159 9 strcpy(item_string[i],old_item_string[i]);
7160 9 tempitem.tile = itemsbuf[iLetter].tile;
7161 9 tempitem.csets = itemsbuf[iLetter].csets;
7162 9 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7163 9 tempitem.frames = itemsbuf[iLetter].frames;
7164 9 tempitem.speed = itemsbuf[iLetter].speed;
7165 9 tempitem.ltm = itemsbuf[iLetter].ltm;
7166 9 }
7167
7168
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 3)
7169 {
7170
3/3
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 2097 times.
✓ Branch 2 taken 9 times.
2304 switch(i)
7171 {
7172 case iRocsFeather:
7173 case iHoverBoots:
7174 case iSpinScroll:
7175 case iL2SpinScroll:
7176 case iCrossScroll:
7177 case iQuakeScroll:
7178 case iL2QuakeScroll:
7179 case iWhispRing:
7180 case iL2WhispRing:
7181 case iChargeRing:
7182 case iL2ChargeRing:
7183 case iPerilScroll:
7184 case iWalletL3:
7185 case iQuiverL4:
7186 case iBombBagL4:
7187 case iBracelet:
7188 case iL2Bracelet:
7189 case iOldGlove:
7190 case iL2Ladder:
7191 case iWealthMedal:
7192 case iL2WealthMedal:
7193 case iL3WealthMedal:
7194 198 reset_itembuf(&tempitem, i);
7195 198 strcpy(item_string[i],old_item_string[i]);
7196 198 break;
7197
7198 case iSShield:
7199 9 reset_itembuf(&tempitem, i);
7200 9 strcpy(item_string[i],old_item_string[i]);
7201 9 strcpy(item_string[iShield],old_item_string[iShield]);
7202 9 strcpy(item_string[iMShield],old_item_string[iMShield]);
7203 9 break;
7204 }
7205 2304 }
7206
7207
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 5)
7208 {
7209
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 2241 times.
2304 switch(i)
7210 {
7211 case iHeartRing:
7212 case iL2HeartRing:
7213 case iL3HeartRing:
7214 case iMagicRing:
7215 case iL2MagicRing:
7216 case iL3MagicRing:
7217 case iL4MagicRing:
7218 63 reset_itembuf(&tempitem, i);
7219 63 strcpy(item_string[i],old_item_string[i]);
7220 63 break;
7221 }
7222 2304 }
7223
7224
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7225 {
7226
4/4
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2286 times.
2304 if(i!=iBPotion && i!=iRPotion)
7227 2286 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7228
7229
43/43
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1899 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 9 times.
✓ Branch 12 taken 9 times.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 9 times.
✓ Branch 16 taken 9 times.
✓ Branch 17 taken 9 times.
✓ Branch 18 taken 9 times.
✓ Branch 19 taken 9 times.
✓ Branch 20 taken 9 times.
✓ Branch 21 taken 9 times.
✓ Branch 22 taken 9 times.
✓ Branch 23 taken 9 times.
✓ Branch 24 taken 9 times.
✓ Branch 25 taken 9 times.
✓ Branch 26 taken 9 times.
✓ Branch 27 taken 9 times.
✓ Branch 28 taken 9 times.
✓ Branch 29 taken 9 times.
✓ Branch 30 taken 9 times.
✓ Branch 31 taken 9 times.
✓ Branch 32 taken 9 times.
✓ Branch 33 taken 9 times.
✓ Branch 34 taken 9 times.
✓ Branch 35 taken 9 times.
✓ Branch 36 taken 9 times.
✓ Branch 37 taken 9 times.
✓ Branch 38 taken 9 times.
✓ Branch 39 taken 9 times.
✓ Branch 40 taken 9 times.
✓ Branch 41 taken 9 times.
✓ Branch 42 taken 9 times.
2304 switch(i)
7230 {
7231 case iTriforce:
7232 9 tempitem.fam_type=1;
7233 9 break;
7234
7235 case iBigTri:
7236 9 tempitem.fam_type=0;
7237 9 break;
7238
7239 case iBombs:
7240 9 tempitem.fam_type=i_bomb;
7241 9 tempitem.power=4;
7242 9 tempitem.wpn=wBOMB;
7243 9 tempitem.wpn2=wBOOM;
7244 9 tempitem.misc1 = 50;
7245
7246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 200; //qr_SLOWBOMBFUSES
7247
7248 9 break;
7249
7250 case iSBomb:
7251 9 tempitem.fam_type=i_sbomb;
7252 9 tempitem.power=16;
7253 9 tempitem.wpn=wSBOMB;
7254 9 tempitem.wpn2=wSBOOM;
7255 9 tempitem.misc1 = 50;
7256
7257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 400; //qr_SLOWBOMBFUSES
7258
7259 9 break;
7260
7261 case iBook:
7262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules, 113))
7263 tempitem.wpn = wFIREMAGIC; //qr_FIREMAGICSPRITE
7264
7265 9 break;
7266
7267 case iSArrow:
7268 9 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7269 9 tempitem.power=4;
7270 9 tempitem.flags|=ITEM_GAMEDATA;
7271 9 tempitem.wpn=wSARROW;
7272 9 break;
7273
7274 case iGArrow:
7275 9 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7276 9 tempitem.power=8;
7277 9 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7278 9 tempitem.wpn=wGARROW;
7279 9 break;
7280
7281 case iBrang:
7282 9 tempitem.power=0;
7283 9 tempitem.wpn=wBRANG;
7284 9 tempitem.misc1=36;
7285 9 break;
7286
7287 case iMBrang:
7288 9 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7289 9 tempitem.power=0;
7290 9 tempitem.wpn=wMBRANG;
7291 9 break;
7292
7293 case iFBrang:
7294 9 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7295 9 tempitem.power=2;
7296 9 tempitem.wpn=wFBRANG;
7297 9 break;
7298
7299 case iBoots:
7300 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,51) ? 1 : 0;
7301 9 tempitem.power=7;
7302 9 break;
7303
7304 case iWand:
7305 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,49) ? 8 : 0;
7306 9 tempitem.power=2;
7307 9 tempitem.wpn=wWAND;
7308 9 tempitem.wpn3=wMAGIC;
7309 9 break;
7310
7311 case iBCandle:
7312 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7313 9 tempitem.power=1;
7314 9 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7315 9 tempitem.wpn3=wFIRE;
7316 9 break;
7317
7318 case iRCandle:
7319 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7320 9 tempitem.power=1;
7321 9 tempitem.wpn3=wFIRE;
7322 9 break;
7323
7324 case iSword:
7325 9 tempitem.power=1;
7326 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7327 9 tempitem.wpn=tempitem.wpn3=wSWORD;
7328 9 tempitem.wpn2=wSWORDSLASH;
7329 9 break;
7330
7331 case iWSword:
7332 9 tempitem.power=2;
7333 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7334 9 tempitem.wpn=tempitem.wpn3=wWSWORD;
7335 9 tempitem.wpn2=wWSWORDSLASH;
7336 9 break;
7337
7338 case iMSword:
7339 9 tempitem.power=4;
7340 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7341 9 tempitem.wpn=tempitem.wpn3=wMSWORD;
7342 9 tempitem.wpn2=wMSWORDSLASH;
7343 9 break;
7344
7345 case iXSword:
7346 9 tempitem.power=8;
7347 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7348 9 tempitem.wpn=tempitem.wpn3=wXSWORD;
7349 9 tempitem.wpn2=wXSWORDSLASH;
7350 9 break;
7351
7352 case iDivineProtection:
7353 9 tempitem.flags |= get_bit(deprecated_rules,76) ? ITEM_FLAG1 : 0;
7354 9 tempitem.flags |= get_bit(deprecated_rules,75) ? ITEM_FLAG2 : 0;
7355 9 tempitem.wpn=wDIVINEPROTECTION1A;
7356 9 tempitem.wpn2=wDIVINEPROTECTION1B;
7357 9 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7358 9 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7359 9 tempitem.wpn6=wDIVINEPROTECTION2A;
7360 9 tempitem.wpn7=wDIVINEPROTECTION2B;
7361 9 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7362 9 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7363 9 tempitem.wpn5 = iwDivineProtectionShieldFront;
7364 9 tempitem.wpn10 = iwDivineProtectionShieldBack;
7365 9 tempitem.misc1=512;
7366 9 tempitem.cost_amount[0]=64;
7367 9 break;
7368
7369 case iLens:
7370 9 tempitem.misc1=60;
7371 9 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7372 9 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7373 9 break;
7374
7375 case iArrow:
7376 9 tempitem.power=2;
7377 9 tempitem.wpn=wARROW;
7378 9 break;
7379
7380 case iHoverBoots:
7381 9 tempitem.misc1=45;
7382 9 tempitem.wpn=iwHover;
7383 9 break;
7384
7385 case iDivineFire:
7386 9 tempitem.power=8;
7387 9 tempitem.wpn=wDIVINEFIRE1A;
7388 9 tempitem.wpn2=wDIVINEFIRE1B;
7389 9 tempitem.wpn3=wDIVINEFIRES1A;
7390 9 tempitem.wpn4=wDIVINEFIRES1B;
7391 9 tempitem.misc1 = 32;
7392 9 tempitem.misc2 = 200;
7393 9 tempitem.cost_amount[0]=32;
7394 9 break;
7395
7396 case iDivineEscape:
7397 9 tempitem.cost_amount[0]=32;
7398 9 break;
7399
7400 case iHookshot:
7401 9 tempitem.power=0;
7402 9 tempitem.flags&=~ITEM_FLAG1;
7403 9 tempitem.wpn=wHSHEAD;
7404 9 tempitem.wpn2=wHSCHAIN_H;
7405 9 tempitem.wpn4=wHSHANDLE;
7406 9 tempitem.wpn3=wHSCHAIN_V;
7407 9 tempitem.misc1=50;
7408 9 tempitem.misc2=100;
7409 9 break;
7410
7411 case iLongshot:
7412 9 tempitem.power=0;
7413 9 tempitem.flags&=~ITEM_FLAG1;
7414 9 tempitem.wpn=wLSHEAD;
7415 9 tempitem.wpn2=wLSCHAIN_H;
7416 9 tempitem.wpn4=wLSHANDLE;
7417 9 tempitem.wpn3=wLSCHAIN_V;
7418 9 tempitem.misc1=99;
7419 9 tempitem.misc2=100;
7420 9 break;
7421
7422 case iHammer:
7423 9 tempitem.power=4;
7424 9 tempitem.wpn=wHAMMER;
7425 9 tempitem.wpn2=iwHammerSmack;
7426 9 break;
7427
7428 case iCByrna:
7429 9 tempitem.power=1;
7430 9 tempitem.wpn=wCBYRNA;
7431 9 tempitem.wpn2=wCBYRNASLASH;
7432 9 tempitem.wpn3=wCBYRNAORB;
7433 9 tempitem.misc1=4;
7434 9 tempitem.misc2=16;
7435 9 tempitem.misc3=1;
7436 9 tempitem.cost_amount[0]=1;
7437 9 break;
7438
7439 case iWhistle:
7440 9 tempitem.wpn=wWIND;
7441 9 tempitem.misc1=3;
7442 9 tempitem.flags|=ITEM_FLAG1;
7443 9 break;
7444
7445 case iBRing:
7446 9 tempitem.power=2;
7447 9 tempitem.misc1=spBLUE;
7448 9 break;
7449
7450 case iRRing:
7451 9 tempitem.power=4;
7452 9 tempitem.misc1=spRED;
7453 9 break;
7454
7455 case iGRing:
7456 9 tempitem.power=8;
7457 9 tempitem.misc1=spGOLD;
7458 9 break;
7459
7460 case iSpinScroll:
7461 9 tempitem.power = 2;
7462 9 tempitem.misc1 = 1;
7463 9 break;
7464
7465 case iL2SpinScroll:
7466 9 tempitem.family=itype_spinscroll2;
7467 9 tempitem.fam_type=1;
7468 9 tempitem.cost_amount[0]=8;
7469 9 tempitem.power=2;
7470 9 tempitem.misc1 = 20;
7471 9 break;
7472
7473 case iQuakeScroll:
7474 9 tempitem.misc1=0x10;
7475 9 tempitem.misc2=64;
7476 9 break;
7477
7478 case iL2QuakeScroll:
7479 9 tempitem.family=itype_quakescroll2;
7480 9 tempitem.fam_type=1;
7481 9 tempitem.power = 2;
7482 9 tempitem.misc1=0x20;
7483 9 tempitem.misc2=192;
7484 9 tempitem.cost_amount[0]=8;
7485 9 break;
7486
7487 case iChargeRing:
7488 9 tempitem.misc1=64;
7489 9 tempitem.misc2=128;
7490 9 break;
7491
7492 case iL2ChargeRing:
7493 9 tempitem.misc1=32;
7494 9 tempitem.misc2=64;
7495 9 break;
7496
7497 case iOldGlove:
7498 9 tempitem.flags |= ITEM_FLAG1;
7499
7500 //fallthrough
7501 case iBombBagL4:
7502 case iWalletL3:
7503 case iQuiverL4:
7504 case iBracelet:
7505 45 tempitem.power = 1;
7506 45 break;
7507
7508 case iL2Bracelet:
7509 9 tempitem.power = 2;
7510 9 break;
7511
7512 case iMKey:
7513 9 tempitem.power=0xFF;
7514 9 tempitem.flags |= ITEM_FLAG1;
7515 9 break;
7516 }
7517 2304 }
7518
7519
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 7)
7520 {
7521
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 2268 times.
2304 switch(i)
7522 {
7523 case iStoneAgony:
7524 case iStompBoots:
7525 case iPerilRing:
7526 case iWhimsicalRing:
7527 {
7528 36 reset_itembuf(&tempitem, i);
7529 36 strcpy(item_string[i],old_item_string[i]);
7530 36 break;
7531 }
7532 }
7533 2304 }
7534
7535
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 8) // May 2007: Some corrections.
7536 {
7537
7/7
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 2232 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
2304 switch(i)
7538 {
7539 case iMShield:
7540 9 tempitem.misc1|=shFLAME;
7541 9 tempitem.misc2|=shFIREBALL|shMAGIC;
7542
7543
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(quest_rules, qr_SWORDMIRROR))
7544 {
7545 tempitem.misc2 |= shSWORD;
7546 }
7547
7548 // fallthrough
7549 case iShield:
7550 18 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7551
7552 // fallthrough
7553 case iSShield:
7554 27 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7555
7556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7557 {
7558 tempitem.misc2 |= shROCK;
7559 }
7560
7561 27 break;
7562
7563 case iWhispRing:
7564 9 tempitem.power=1;
7565 9 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7566 9 tempitem.misc1 = 3;
7567 9 break;
7568
7569 case iL2WhispRing:
7570 9 tempitem.power=0;
7571 9 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7572 9 tempitem.misc1 = 3;
7573 9 break;
7574
7575 case iL2Ladder:
7576 case iBow:
7577 case iCByrna:
7578 27 tempitem.power = 1;
7579 27 break;
7580 }
7581 2304 }
7582
7583
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 26880 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
29184 if(s_version < 9 && i==iClock)
7584 {
7585 9 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7586 9 }
7587
7588 //add the misc flag for bomb
7589
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 26880 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
29184 if(s_version < 10 && tempitem.family == itype_bomb)
7590 {
7591 9 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7592 9 }
7593
7594
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 26880 times.
✓ Branch 2 taken 2286 times.
✓ Branch 3 taken 18 times.
29184 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7595 {
7596 18 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7597 18 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7598 18 }
7599
7600
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 12) // June 2007: More Misc. attributes.
7601 {
7602
5/5
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2259 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
2304 switch(i)
7603 {
7604 case iFBrang:
7605 9 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7606
7607 //fallthrough
7608 case iMBrang:
7609 18 tempitem.misc3 |= shSWORD|shMAGIC;
7610
7611 //fallthrough
7612 case iHookshot:
7613 case iLongshot:
7614 //fallthrough
7615 36 tempitem.misc3 |= shFIREBALL;
7616
7617 case iBrang:
7618 45 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7619 45 break;
7620 }
7621
7622
16/16
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 1298 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 27 times.
✓ Branch 12 taken 27 times.
✓ Branch 13 taken 781 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 9 times.
2304 switch(tempitem.family)
7623 {
7624 case itype_hoverboots:
7625 9 tempitem.usesound = WAV_ZN1HOVER;
7626 9 break;
7627
7628 case itype_wand:
7629 9 tempitem.usesound = WAV_WAND;
7630 9 break;
7631
7632 case itype_book:
7633 9 tempitem.usesound = WAV_FIRE;
7634 9 break;
7635
7636 case itype_arrow:
7637 27 tempitem.usesound = WAV_ARROW;
7638 27 break;
7639
7640 case itype_hookshot:
7641 18 tempitem.usesound = WAV_HOOKSHOT;
7642 18 break;
7643
7644 case itype_brang:
7645 27 tempitem.usesound = WAV_BRANG;
7646 27 break;
7647
7648 case itype_shield:
7649 27 tempitem.usesound = WAV_CHINK;
7650 27 break;
7651
7652 case itype_sword:
7653 781 tempitem.usesound = WAV_SWORD;
7654 781 break;
7655
7656 case itype_whistle:
7657 9 tempitem.usesound = WAV_WHISTLE;
7658 9 break;
7659
7660 case itype_hammer:
7661 9 tempitem.usesound = WAV_HAMMER;
7662 9 break;
7663
7664 case itype_divinefire:
7665 9 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7666 9 break;
7667
7668 case itype_divineescape:
7669 9 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7670 9 break;
7671
7672 case itype_divineprotection:
7673 9 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7674 9 break;
7675
7676 case itype_bomb:
7677 case itype_sbomb:
7678 case itype_quakescroll:
7679 case itype_quakescroll2:
7680 36 tempitem.usesound = WAV_BOMB;
7681 36 break;
7682
7683 case itype_spinscroll:
7684 case itype_spinscroll2:
7685 18 tempitem.usesound = WAV_ZN1SPINATTACK;
7686 18 break;
7687 }
7688 2304 }
7689
7690
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 13) // July 2007
7691 {
7692
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_whistle)
7693 {
7694 9 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7695 9 tempitem.power = 1;
7696 9 tempitem.flags|=ITEM_FLAG1;
7697 9 }
7698
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2286 times.
2295 else if(tempitem.family == itype_wand)
7699 9 tempitem.flags|=ITEM_FLAG1;
7700
2/2
✓ Branch 0 taken 2277 times.
✓ Branch 1 taken 9 times.
2286 else if(tempitem.family == itype_book)
7701 {
7702 9 tempitem.flags|=ITEM_FLAG1;
7703 9 tempitem.power = 2;
7704 9 }
7705 2304 }
7706
7707
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 14) // August 2007
7708 {
7709
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2286 times.
2304 if(tempitem.family == itype_fairy)
7710 {
7711 18 tempitem.usesound = WAV_SCALE;
7712
7713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(tempitem.fam_type)
7714 18 tempitem.misc3=50;
7715 18 }
7716
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 18 times.
2286 else if(tempitem.family == itype_potion)
7717 {
7718 18 tempitem.flags |= ITEM_GAINOLD;
7719 18 }
7720 2304 }
7721
7722
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 17) // November 2007
7723 {
7724
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2286 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
2304 if(tempitem.family == itype_candle && !tempitem.wpn3)
7725 {
7726 tempitem.wpn3 = wFIRE;
7727 }
7728
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2277 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
2304 else if(tempitem.family == itype_arrow && tempitem.power>4)
7729 {
7730 9 tempitem.flags|=ITEM_FLAG1;
7731 9 }
7732 2304 }
7733
7734
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 18) // New Year's Eve 2007
7735 {
7736
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_whistle)
7737 9 tempitem.misc2 = 8; // Use the Whistle warp ring
7738
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2286 times.
2295 else if(tempitem.family == itype_bait)
7739 9 tempitem.misc1 = 768; // Frames until it goes
7740
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 18 times.
2286 else if(tempitem.family == itype_triforcepiece)
7741 {
7742
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if(tempitem.flags & ITEM_GAMEDATA)
7743 {
7744 9 tempitem.misc2 = 1; // Cutscene 1
7745 9 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7746 9 }
7747 18 }
7748 2304 }
7749
7750
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 19) // January 2008
7751 {
7752
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divineprotection)
7753 {
7754 9 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7755 9 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7756 9 }
7757 2304 }
7758
7759
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 20) // October 2008
7760 {
7761
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divineprotection)
7762 {
7763 9 tempitem.wpn6=wDIVINEPROTECTION2A;
7764 9 tempitem.wpn7=wDIVINEPROTECTION2B;
7765 9 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7766 9 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7767 9 tempitem.wpn5 = iwDivineProtectionShieldFront;
7768 9 tempitem.wpn10 = iwDivineProtectionShieldBack;
7769 9 }
7770 2304 }
7771
7772
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 21) // November 2008
7773 {
7774
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if(tempitem.flags & 0x0100) // ITEM_SLASH
7775 {
7776 tempitem.flags &= ~0x0100;
7777
7778 if(tempitem.family == itype_sword ||
7779 tempitem.family == itype_wand ||
7780 tempitem.family == itype_candle ||
7781 tempitem.family == itype_cbyrna)
7782 {
7783 tempitem.flags |= ITEM_FLAG4;
7784 }
7785 }
7786 2304 }
7787
7788
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 22) // September 2009
7789 {
7790
4/4
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2286 times.
2304 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7791 {
7792 18 tempitem.misc3 = tempitem.power/2;
7793 18 }
7794 2304 }
7795
7796
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 23) // March 2011
7797 {
7798
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_divinefire)
7799 9 tempitem.wpn5 = wFIRE;
7800
2/2
✓ Branch 0 taken 2286 times.
✓ Branch 1 taken 9 times.
2295 else if(tempitem.family == itype_book)
7801 9 tempitem.wpn2 = wFIRE;
7802 2304 }
7803
7804 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7805 // whether it was or not, and a lot of existing quests depended on the
7806 // incorrect behavior.
7807
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 2304 times.
29184 if(s_version < 25) // January 2012
7808 {
7809
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 36 times.
2304 if(tempitem.family == itype_bombbag)
7810 36 tempitem.flags |= 16;
7811
7812
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divinefire)
7813 9 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7814 2304 }
7815
7816
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7817 {
7818
60/60
✓ Branch 0 taken 6848 times.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 130 times.
✓ Branch 5 taken 85 times.
✓ Branch 6 taken 168 times.
✓ Branch 7 taken 167 times.
✓ Branch 8 taken 99 times.
✓ Branch 9 taken 278 times.
✓ Branch 10 taken 252 times.
✓ Branch 11 taken 167 times.
✓ Branch 12 taken 259 times.
✓ Branch 13 taken 168 times.
✓ Branch 14 taken 84 times.
✓ Branch 15 taken 168 times.
✓ Branch 16 taken 99 times.
✓ Branch 17 taken 84 times.
✓ Branch 18 taken 255 times.
✓ Branch 19 taken 85 times.
✓ Branch 20 taken 86 times.
✓ Branch 21 taken 168 times.
✓ Branch 22 taken 84 times.
✓ Branch 23 taken 85 times.
✓ Branch 24 taken 84 times.
✓ Branch 25 taken 84 times.
✓ Branch 26 taken 84 times.
✓ Branch 27 taken 99 times.
✓ Branch 28 taken 84 times.
✓ Branch 29 taken 85 times.
✓ Branch 30 taken 84 times.
✓ Branch 31 taken 85 times.
✓ Branch 32 taken 168 times.
✓ Branch 33 taken 336 times.
✓ Branch 34 taken 86 times.
✓ Branch 35 taken 84 times.
✓ Branch 36 taken 152 times.
✓ Branch 37 taken 336 times.
✓ Branch 38 taken 84 times.
✓ Branch 39 taken 84 times.
✓ Branch 40 taken 84 times.
✓ Branch 41 taken 84 times.
✓ Branch 42 taken 84 times.
✓ Branch 43 taken 169 times.
✓ Branch 44 taken 168 times.
✓ Branch 45 taken 84 times.
✓ Branch 46 taken 253 times.
✓ Branch 47 taken 254 times.
✓ Branch 48 taken 340 times.
✓ Branch 49 taken 84 times.
✓ Branch 50 taken 84 times.
✓ Branch 51 taken 84 times.
✓ Branch 52 taken 84 times.
✓ Branch 53 taken 84 times.
✓ Branch 54 taken 85 times.
✓ Branch 55 taken 2368 times.
✓ Branch 56 taken 903 times.
✓ Branch 57 taken 253 times.
✓ Branch 58 taken 1047 times.
✓ Branch 59 taken 2617 times.
21760 switch(tempitem.family)
7819 {
7820 case itype_sword:
7821 {
7822 6848 tempitem.flags &= ~(ITEM_FLAG5);
7823 6848 tempitem.misc3 = 0;
7824 6848 tempitem.misc4 = 0;
7825 6848 tempitem.misc5 = 0;
7826 6848 tempitem.misc6 = 0;
7827 6848 tempitem.misc7 = 0;
7828 6848 tempitem.misc8 = 0;
7829 6848 tempitem.misc9 = 0;
7830 6848 tempitem.misc10 = 0;
7831 6848 tempitem.wpn4 = 0;
7832 6848 tempitem.wpn5 = 0;
7833 6848 tempitem.wpn6 = 0;
7834 6848 tempitem.wpn7 = 0;
7835 6848 tempitem.wpn8 = 0;
7836 6848 tempitem.wpn9 = 0;
7837 6848 tempitem.wpn10 = 0;
7838 6848 break;
7839 }
7840 case itype_brang:
7841 {
7842 253 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7843 253 tempitem.misc2 = 0;
7844 253 tempitem.misc5 = 0;
7845 253 tempitem.misc6 = 0;
7846 253 tempitem.misc7 = 0;
7847 253 tempitem.misc8 = 0;
7848 253 tempitem.misc9 = 0;
7849 253 tempitem.misc10 = 0;
7850 253 tempitem.wpn4 = 0;
7851 253 tempitem.wpn5 = 0;
7852 253 tempitem.wpn6 = 0;
7853 253 tempitem.wpn7 = 0;
7854 253 tempitem.wpn8 = 0;
7855 253 tempitem.wpn9 = 0;
7856 253 tempitem.wpn10 = 0;
7857 253 break;
7858 }
7859 case itype_arrow:
7860 {
7861 250 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7862 250 tempitem.misc2 = 0;
7863 250 tempitem.misc3 = 0;
7864 250 tempitem.misc4 = 0;
7865 250 tempitem.misc5 = 0;
7866 250 tempitem.misc6 = 0;
7867 250 tempitem.misc7 = 0;
7868 250 tempitem.misc8 = 0;
7869 250 tempitem.misc9 = 0;
7870 250 tempitem.misc10 = 0;
7871 250 tempitem.wpn4 = 0;
7872 250 tempitem.wpn5 = 0;
7873 250 tempitem.wpn6 = 0;
7874 250 tempitem.wpn7 = 0;
7875 250 tempitem.wpn8 = 0;
7876 250 tempitem.wpn9 = 0;
7877 250 tempitem.wpn10 = 0;
7878 250 break;
7879 }
7880 case itype_candle:
7881 {
7882 206 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7883 206 tempitem.misc1 = 0;
7884 206 tempitem.misc2 = 0;
7885 206 tempitem.misc3 = 0;
7886 206 tempitem.misc4 = 0;
7887 206 tempitem.misc5 = 0;
7888 206 tempitem.misc6 = 0;
7889 206 tempitem.misc7 = 0;
7890 206 tempitem.misc8 = 0;
7891 206 tempitem.misc9 = 0;
7892 206 tempitem.misc10 = 0;
7893 206 tempitem.wpn4 = 0;
7894 206 tempitem.wpn5 = 0;
7895 206 tempitem.wpn6 = 0;
7896 206 tempitem.wpn7 = 0;
7897 206 tempitem.wpn8 = 0;
7898 206 tempitem.wpn9 = 0;
7899 206 tempitem.wpn10 = 0;
7900 206 break;
7901 }
7902 case itype_whistle:
7903 {
7904 130 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7905 130 tempitem.misc3 = 0;
7906 130 tempitem.misc4 = 0;
7907 130 tempitem.misc5 = 0;
7908 130 tempitem.misc6 = 0;
7909 130 tempitem.misc7 = 0;
7910 130 tempitem.misc8 = 0;
7911 130 tempitem.misc9 = 0;
7912 130 tempitem.misc10 = 0;
7913 130 tempitem.wpn2 = 0;
7914 130 tempitem.wpn3 = 0;
7915 130 tempitem.wpn4 = 0;
7916 130 tempitem.wpn5 = 0;
7917 130 tempitem.wpn6 = 0;
7918 130 tempitem.wpn7 = 0;
7919 130 tempitem.wpn8 = 0;
7920 130 tempitem.wpn9 = 0;
7921 130 tempitem.wpn10 = 0;
7922 130 break;
7923 }
7924 case itype_bait:
7925 {
7926 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7927 85 tempitem.misc2 = 0;
7928 85 tempitem.misc3 = 0;
7929 85 tempitem.misc4 = 0;
7930 85 tempitem.misc5 = 0;
7931 85 tempitem.misc6 = 0;
7932 85 tempitem.misc7 = 0;
7933 85 tempitem.misc8 = 0;
7934 85 tempitem.misc9 = 0;
7935 85 tempitem.misc10 = 0;
7936 85 tempitem.wpn2 = 0;
7937 85 tempitem.wpn3 = 0;
7938 85 tempitem.wpn4 = 0;
7939 85 tempitem.wpn5 = 0;
7940 85 tempitem.wpn6 = 0;
7941 85 tempitem.wpn7 = 0;
7942 85 tempitem.wpn8 = 0;
7943 85 tempitem.wpn9 = 0;
7944 85 tempitem.wpn10 = 0;
7945 85 break;
7946 }
7947 case itype_letter:
7948 {
7949 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7950 168 tempitem.misc1 = 0;
7951 168 tempitem.misc2 = 0;
7952 168 tempitem.misc3 = 0;
7953 168 tempitem.misc4 = 0;
7954 168 tempitem.misc5 = 0;
7955 168 tempitem.misc6 = 0;
7956 168 tempitem.misc7 = 0;
7957 168 tempitem.misc8 = 0;
7958 168 tempitem.misc9 = 0;
7959 168 tempitem.misc10 = 0;
7960 168 tempitem.wpn = 0;
7961 168 tempitem.wpn2 = 0;
7962 168 tempitem.wpn3 = 0;
7963 168 tempitem.wpn4 = 0;
7964 168 tempitem.wpn5 = 0;
7965 168 tempitem.wpn6 = 0;
7966 168 tempitem.wpn7 = 0;
7967 168 tempitem.wpn8 = 0;
7968 168 tempitem.wpn9 = 0;
7969 168 tempitem.wpn10 = 0;
7970 168 break;
7971 }
7972 case itype_potion:
7973 {
7974 167 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7975 167 tempitem.misc3 = 0;
7976 167 tempitem.misc4 = 0;
7977 167 tempitem.misc5 = 0;
7978 167 tempitem.misc6 = 0;
7979 167 tempitem.misc7 = 0;
7980 167 tempitem.misc8 = 0;
7981 167 tempitem.misc9 = 0;
7982 167 tempitem.misc10 = 0;
7983 167 tempitem.wpn = 0;
7984 167 tempitem.wpn2 = 0;
7985 167 tempitem.wpn3 = 0;
7986 167 tempitem.wpn4 = 0;
7987 167 tempitem.wpn5 = 0;
7988 167 tempitem.wpn6 = 0;
7989 167 tempitem.wpn7 = 0;
7990 167 tempitem.wpn8 = 0;
7991 167 tempitem.wpn9 = 0;
7992 167 tempitem.wpn10 = 0;
7993 167 break;
7994 }
7995 case itype_wand:
7996 {
7997 99 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7998 99 tempitem.misc1 = 0;
7999 99 tempitem.misc2 = 0;
8000 99 tempitem.misc3 = 0;
8001 99 tempitem.misc4 = 0;
8002 99 tempitem.misc5 = 0;
8003 99 tempitem.misc6 = 0;
8004 99 tempitem.misc7 = 0;
8005 99 tempitem.misc8 = 0;
8006 99 tempitem.misc9 = 0;
8007 99 tempitem.misc10 = 0;
8008 99 tempitem.wpn4 = 0;
8009 99 tempitem.wpn5 = 0;
8010 99 tempitem.wpn6 = 0;
8011 99 tempitem.wpn7 = 0;
8012 99 tempitem.wpn8 = 0;
8013 99 tempitem.wpn9 = 0;
8014 99 tempitem.wpn10 = 0;
8015 99 break;
8016 }
8017 case itype_ring:
8018 {
8019 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8020 278 tempitem.misc2 = 0;
8021 278 tempitem.misc3 = 0;
8022 278 tempitem.misc4 = 0;
8023 278 tempitem.misc5 = 0;
8024 278 tempitem.misc6 = 0;
8025 278 tempitem.misc7 = 0;
8026 278 tempitem.misc8 = 0;
8027 278 tempitem.misc9 = 0;
8028 278 tempitem.misc10 = 0;
8029 278 tempitem.wpn = 0;
8030 278 tempitem.wpn2 = 0;
8031 278 tempitem.wpn3 = 0;
8032 278 tempitem.wpn4 = 0;
8033 278 tempitem.wpn5 = 0;
8034 278 tempitem.wpn6 = 0;
8035 278 tempitem.wpn7 = 0;
8036 278 tempitem.wpn8 = 0;
8037 278 tempitem.wpn9 = 0;
8038 278 tempitem.wpn10 = 0;
8039 278 break;
8040 }
8041 case itype_wallet:
8042 {
8043 252 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8044 252 tempitem.misc3 = 0;
8045 252 tempitem.misc4 = 0;
8046 252 tempitem.misc5 = 0;
8047 252 tempitem.misc6 = 0;
8048 252 tempitem.misc7 = 0;
8049 252 tempitem.misc8 = 0;
8050 252 tempitem.misc9 = 0;
8051 252 tempitem.misc10 = 0;
8052 252 tempitem.wpn = 0;
8053 252 tempitem.wpn2 = 0;
8054 252 tempitem.wpn3 = 0;
8055 252 tempitem.wpn4 = 0;
8056 252 tempitem.wpn5 = 0;
8057 252 tempitem.wpn6 = 0;
8058 252 tempitem.wpn7 = 0;
8059 252 tempitem.wpn8 = 0;
8060 252 tempitem.wpn9 = 0;
8061 252 tempitem.wpn10 = 0;
8062 252 break;
8063 }
8064 case itype_amulet:
8065 {
8066 167 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8067 167 tempitem.misc1 = 0;
8068 167 tempitem.misc2 = 0;
8069 167 tempitem.misc3 = 0;
8070 167 tempitem.misc4 = 0;
8071 167 tempitem.misc5 = 0;
8072 167 tempitem.misc6 = 0;
8073 167 tempitem.misc7 = 0;
8074 167 tempitem.misc8 = 0;
8075 167 tempitem.misc9 = 0;
8076 167 tempitem.misc10 = 0;
8077 167 tempitem.wpn = 0;
8078 167 tempitem.wpn2 = 0;
8079 167 tempitem.wpn3 = 0;
8080 167 tempitem.wpn4 = 0;
8081 167 tempitem.wpn5 = 0;
8082 167 tempitem.wpn6 = 0;
8083 167 tempitem.wpn7 = 0;
8084 167 tempitem.wpn8 = 0;
8085 167 tempitem.wpn9 = 0;
8086 167 tempitem.wpn10 = 0;
8087 167 break;
8088 }
8089 case itype_shield:
8090 {
8091 259 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8092 259 tempitem.misc3 = 0;
8093 259 tempitem.misc4 = 0;
8094 259 tempitem.misc5 = 0;
8095 259 tempitem.misc6 = 0;
8096 259 tempitem.misc7 = 0;
8097 259 tempitem.misc8 = 0;
8098 259 tempitem.misc9 = 0;
8099 259 tempitem.misc10 = 0;
8100 259 tempitem.wpn = 0;
8101 259 tempitem.wpn2 = 0;
8102 259 tempitem.wpn3 = 0;
8103 259 tempitem.wpn4 = 0;
8104 259 tempitem.wpn5 = 0;
8105 259 tempitem.wpn6 = 0;
8106 259 tempitem.wpn7 = 0;
8107 259 tempitem.wpn8 = 0;
8108 259 tempitem.wpn9 = 0;
8109 259 tempitem.wpn10 = 0;
8110 259 break;
8111 }
8112 case itype_bow:
8113 {
8114 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8115 168 tempitem.misc1 = 0;
8116 168 tempitem.misc2 = 0;
8117 168 tempitem.misc3 = 0;
8118 168 tempitem.misc4 = 0;
8119 168 tempitem.misc5 = 0;
8120 168 tempitem.misc6 = 0;
8121 168 tempitem.misc7 = 0;
8122 168 tempitem.misc8 = 0;
8123 168 tempitem.misc9 = 0;
8124 168 tempitem.misc10 = 0;
8125 168 tempitem.wpn = 0;
8126 168 tempitem.wpn2 = 0;
8127 168 tempitem.wpn3 = 0;
8128 168 tempitem.wpn4 = 0;
8129 168 tempitem.wpn5 = 0;
8130 168 tempitem.wpn6 = 0;
8131 168 tempitem.wpn7 = 0;
8132 168 tempitem.wpn8 = 0;
8133 168 tempitem.wpn9 = 0;
8134 168 tempitem.wpn10 = 0;
8135 168 break;
8136 }
8137 case itype_raft:
8138 {
8139 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8140 84 tempitem.misc1 = 0;
8141 84 tempitem.misc2 = 0;
8142 84 tempitem.misc3 = 0;
8143 84 tempitem.misc4 = 0;
8144 84 tempitem.misc5 = 0;
8145 84 tempitem.misc6 = 0;
8146 84 tempitem.misc7 = 0;
8147 84 tempitem.misc8 = 0;
8148 84 tempitem.misc9 = 0;
8149 84 tempitem.misc10 = 0;
8150 84 tempitem.wpn = 0;
8151 84 tempitem.wpn2 = 0;
8152 84 tempitem.wpn3 = 0;
8153 84 tempitem.wpn4 = 0;
8154 84 tempitem.wpn5 = 0;
8155 84 tempitem.wpn6 = 0;
8156 84 tempitem.wpn7 = 0;
8157 84 tempitem.wpn8 = 0;
8158 84 tempitem.wpn9 = 0;
8159 84 tempitem.wpn10 = 0;
8160 84 break;
8161 }
8162 case itype_ladder:
8163 {
8164 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8165 168 tempitem.misc1 = 0;
8166 168 tempitem.misc2 = 0;
8167 168 tempitem.misc3 = 0;
8168 168 tempitem.misc4 = 0;
8169 168 tempitem.misc5 = 0;
8170 168 tempitem.misc6 = 0;
8171 168 tempitem.misc7 = 0;
8172 168 tempitem.misc8 = 0;
8173 168 tempitem.misc9 = 0;
8174 168 tempitem.misc10 = 0;
8175 168 tempitem.wpn = 0;
8176 168 tempitem.wpn2 = 0;
8177 168 tempitem.wpn3 = 0;
8178 168 tempitem.wpn4 = 0;
8179 168 tempitem.wpn5 = 0;
8180 168 tempitem.wpn6 = 0;
8181 168 tempitem.wpn7 = 0;
8182 168 tempitem.wpn8 = 0;
8183 168 tempitem.wpn9 = 0;
8184 168 tempitem.wpn10 = 0;
8185 168 break;
8186 }
8187 case itype_book:
8188 {
8189 99 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8190 99 tempitem.misc1 = 0;
8191 99 tempitem.misc2 = 0;
8192 99 tempitem.misc3 = 0;
8193 99 tempitem.misc4 = 0;
8194 99 tempitem.misc5 = 0;
8195 99 tempitem.misc6 = 0;
8196 99 tempitem.misc7 = 0;
8197 99 tempitem.misc8 = 0;
8198 99 tempitem.misc9 = 0;
8199 99 tempitem.misc10 = 0;
8200 99 tempitem.wpn3 = 0;
8201 99 tempitem.wpn4 = 0;
8202 99 tempitem.wpn5 = 0;
8203 99 tempitem.wpn6 = 0;
8204 99 tempitem.wpn7 = 0;
8205 99 tempitem.wpn8 = 0;
8206 99 tempitem.wpn9 = 0;
8207 99 tempitem.wpn10 = 0;
8208 99 break;
8209 }
8210 case itype_magickey:
8211 {
8212 84 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8213 84 tempitem.misc1 = 0;
8214 84 tempitem.misc2 = 0;
8215 84 tempitem.misc3 = 0;
8216 84 tempitem.misc4 = 0;
8217 84 tempitem.misc5 = 0;
8218 84 tempitem.misc6 = 0;
8219 84 tempitem.misc7 = 0;
8220 84 tempitem.misc8 = 0;
8221 84 tempitem.misc9 = 0;
8222 84 tempitem.misc10 = 0;
8223 84 tempitem.wpn = 0;
8224 84 tempitem.wpn2 = 0;
8225 84 tempitem.wpn3 = 0;
8226 84 tempitem.wpn4 = 0;
8227 84 tempitem.wpn5 = 0;
8228 84 tempitem.wpn6 = 0;
8229 84 tempitem.wpn7 = 0;
8230 84 tempitem.wpn8 = 0;
8231 84 tempitem.wpn9 = 0;
8232 84 tempitem.wpn10 = 0;
8233 84 break;
8234 }
8235 case itype_bracelet:
8236 {
8237 255 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8238 255 tempitem.misc1 = 0;
8239 255 tempitem.misc2 = 0;
8240 255 tempitem.misc3 = 0;
8241 255 tempitem.misc4 = 0;
8242 255 tempitem.misc5 = 0;
8243 255 tempitem.misc6 = 0;
8244 255 tempitem.misc7 = 0;
8245 255 tempitem.misc8 = 0;
8246 255 tempitem.misc9 = 0;
8247 255 tempitem.misc10 = 0;
8248 255 tempitem.wpn = 0;
8249 255 tempitem.wpn2 = 0;
8250 255 tempitem.wpn3 = 0;
8251 255 tempitem.wpn4 = 0;
8252 255 tempitem.wpn5 = 0;
8253 255 tempitem.wpn6 = 0;
8254 255 tempitem.wpn7 = 0;
8255 255 tempitem.wpn8 = 0;
8256 255 tempitem.wpn9 = 0;
8257 255 tempitem.wpn10 = 0;
8258 255 break;
8259 }
8260 case itype_flippers:
8261 {
8262 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8263 85 tempitem.misc1 = 0;
8264 85 tempitem.misc2 = 0;
8265 85 tempitem.misc3 = 0;
8266 85 tempitem.misc4 = 0;
8267 85 tempitem.misc5 = 0;
8268 85 tempitem.misc6 = 0;
8269 85 tempitem.misc7 = 0;
8270 85 tempitem.misc8 = 0;
8271 85 tempitem.misc9 = 0;
8272 85 tempitem.misc10 = 0;
8273 85 tempitem.wpn = 0;
8274 85 tempitem.wpn2 = 0;
8275 85 tempitem.wpn3 = 0;
8276 85 tempitem.wpn4 = 0;
8277 85 tempitem.wpn5 = 0;
8278 85 tempitem.wpn6 = 0;
8279 85 tempitem.wpn7 = 0;
8280 85 tempitem.wpn8 = 0;
8281 85 tempitem.wpn9 = 0;
8282 85 tempitem.wpn10 = 0;
8283 85 break;
8284 }
8285 case itype_boots:
8286 {
8287 86 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8288 86 tempitem.misc1 = 0;
8289 86 tempitem.misc2 = 0;
8290 86 tempitem.misc3 = 0;
8291 86 tempitem.misc4 = 0;
8292 86 tempitem.misc5 = 0;
8293 86 tempitem.misc6 = 0;
8294 86 tempitem.misc7 = 0;
8295 86 tempitem.misc8 = 0;
8296 86 tempitem.misc9 = 0;
8297 86 tempitem.misc10 = 0;
8298 86 tempitem.wpn = 0;
8299 86 tempitem.wpn2 = 0;
8300 86 tempitem.wpn3 = 0;
8301 86 tempitem.wpn4 = 0;
8302 86 tempitem.wpn5 = 0;
8303 86 tempitem.wpn6 = 0;
8304 86 tempitem.wpn7 = 0;
8305 86 tempitem.wpn8 = 0;
8306 86 tempitem.wpn9 = 0;
8307 86 tempitem.wpn10 = 0;
8308 86 break;
8309 }
8310 case itype_hookshot:
8311 {
8312 168 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8313 168 tempitem.misc5 = 0;
8314 168 tempitem.misc6 = 0;
8315 168 tempitem.misc7 = 0;
8316 168 tempitem.misc8 = 0;
8317 168 tempitem.misc9 = 0;
8318 168 tempitem.misc10 = 0;
8319 168 tempitem.wpn5 = 0;
8320 168 tempitem.wpn6 = 0;
8321 168 tempitem.wpn7 = 0;
8322 168 tempitem.wpn8 = 0;
8323 168 tempitem.wpn9 = 0;
8324 168 tempitem.wpn10 = 0;
8325 168 break;
8326 }
8327 case itype_lens:
8328 {
8329 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8330 84 tempitem.misc2 = 0;
8331 84 tempitem.misc3 = 0;
8332 84 tempitem.misc4 = 0;
8333 84 tempitem.misc5 = 0;
8334 84 tempitem.misc6 = 0;
8335 84 tempitem.misc7 = 0;
8336 84 tempitem.misc8 = 0;
8337 84 tempitem.misc9 = 0;
8338 84 tempitem.misc10 = 0;
8339 84 tempitem.wpn = 0;
8340 84 tempitem.wpn2 = 0;
8341 84 tempitem.wpn3 = 0;
8342 84 tempitem.wpn4 = 0;
8343 84 tempitem.wpn5 = 0;
8344 84 tempitem.wpn6 = 0;
8345 84 tempitem.wpn7 = 0;
8346 84 tempitem.wpn8 = 0;
8347 84 tempitem.wpn9 = 0;
8348 84 tempitem.wpn10 = 0;
8349 84 break;
8350 }
8351 case itype_hammer:
8352 {
8353 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8354 85 tempitem.misc1 = 0;
8355 85 tempitem.misc2 = 0;
8356 85 tempitem.misc3 = 0;
8357 85 tempitem.misc4 = 0;
8358 85 tempitem.misc5 = 0;
8359 85 tempitem.misc6 = 0;
8360 85 tempitem.misc7 = 0;
8361 85 tempitem.misc8 = 0;
8362 85 tempitem.misc9 = 0;
8363 85 tempitem.misc10 = 0;
8364 85 tempitem.wpn3 = 0;
8365 85 tempitem.wpn4 = 0;
8366 85 tempitem.wpn5 = 0;
8367 85 tempitem.wpn6 = 0;
8368 85 tempitem.wpn7 = 0;
8369 85 tempitem.wpn8 = 0;
8370 85 tempitem.wpn9 = 0;
8371 85 tempitem.wpn10 = 0;
8372 85 break;
8373 }
8374 case itype_divinefire:
8375 {
8376 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8377 84 tempitem.misc3 = 0;
8378 84 tempitem.misc4 = 0;
8379 84 tempitem.misc5 = 0;
8380 84 tempitem.misc6 = 0;
8381 84 tempitem.misc7 = 0;
8382 84 tempitem.misc8 = 0;
8383 84 tempitem.misc9 = 0;
8384 84 tempitem.misc10 = 0;
8385 84 tempitem.wpn6 = 0;
8386 84 tempitem.wpn7 = 0;
8387 84 tempitem.wpn8 = 0;
8388 84 tempitem.wpn9 = 0;
8389 84 tempitem.wpn10 = 0;
8390 84 break;
8391 }
8392 case itype_divineescape:
8393 {
8394 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8395 84 tempitem.misc2 = 0;
8396 84 tempitem.misc3 = 0;
8397 84 tempitem.misc4 = 0;
8398 84 tempitem.misc5 = 0;
8399 84 tempitem.misc6 = 0;
8400 84 tempitem.misc7 = 0;
8401 84 tempitem.misc8 = 0;
8402 84 tempitem.misc9 = 0;
8403 84 tempitem.misc10 = 0;
8404 84 tempitem.wpn = 0;
8405 84 tempitem.wpn2 = 0;
8406 84 tempitem.wpn3 = 0;
8407 84 tempitem.wpn4 = 0;
8408 84 tempitem.wpn5 = 0;
8409 84 tempitem.wpn6 = 0;
8410 84 tempitem.wpn7 = 0;
8411 84 tempitem.wpn8 = 0;
8412 84 tempitem.wpn9 = 0;
8413 84 tempitem.wpn10 = 0;
8414 84 break;
8415 }
8416 case itype_divineprotection:
8417 {
8418 84 tempitem.flags &= ~ (ITEM_FLAG5);
8419 84 tempitem.misc2 = 0;
8420 84 tempitem.misc3 = 0;
8421 84 tempitem.misc4 = 0;
8422 84 tempitem.misc5 = 0;
8423 84 tempitem.misc6 = 0;
8424 84 tempitem.misc7 = 0;
8425 84 tempitem.misc8 = 0;
8426 84 tempitem.misc9 = 0;
8427 84 tempitem.misc10 = 0;
8428 84 break;
8429 }
8430 case itype_bomb:
8431 {
8432 99 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8433 99 tempitem.misc4 = 0;
8434 99 tempitem.misc5 = 0;
8435 99 tempitem.misc6 = 0;
8436 99 tempitem.misc7 = 0;
8437 99 tempitem.misc8 = 0;
8438 99 tempitem.misc9 = 0;
8439 99 tempitem.misc10 = 0;
8440 99 tempitem.wpn3 = 0;
8441 99 tempitem.wpn4 = 0;
8442 99 tempitem.wpn5 = 0;
8443 99 tempitem.wpn6 = 0;
8444 99 tempitem.wpn7 = 0;
8445 99 tempitem.wpn8 = 0;
8446 99 tempitem.wpn9 = 0;
8447 99 tempitem.wpn10 = 0;
8448 99 break;
8449 }
8450 case itype_sbomb:
8451 {
8452 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8453 84 tempitem.misc4 = 0;
8454 84 tempitem.misc5 = 0;
8455 84 tempitem.misc6 = 0;
8456 84 tempitem.misc7 = 0;
8457 84 tempitem.misc8 = 0;
8458 84 tempitem.misc9 = 0;
8459 84 tempitem.misc10 = 0;
8460 84 tempitem.wpn3 = 0;
8461 84 tempitem.wpn4 = 0;
8462 84 tempitem.wpn5 = 0;
8463 84 tempitem.wpn6 = 0;
8464 84 tempitem.wpn7 = 0;
8465 84 tempitem.wpn8 = 0;
8466 84 tempitem.wpn9 = 0;
8467 84 tempitem.wpn10 = 0;
8468 84 break;
8469 }
8470 case itype_clock:
8471 {
8472 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8473 85 tempitem.misc2 = 0;
8474 85 tempitem.misc3 = 0;
8475 85 tempitem.misc4 = 0;
8476 85 tempitem.misc5 = 0;
8477 85 tempitem.misc6 = 0;
8478 85 tempitem.misc7 = 0;
8479 85 tempitem.misc8 = 0;
8480 85 tempitem.misc9 = 0;
8481 85 tempitem.misc10 = 0;
8482 85 tempitem.wpn = 0;
8483 85 tempitem.wpn2 = 0;
8484 85 tempitem.wpn3 = 0;
8485 85 tempitem.wpn4 = 0;
8486 85 tempitem.wpn5 = 0;
8487 85 tempitem.wpn6 = 0;
8488 85 tempitem.wpn7 = 0;
8489 85 tempitem.wpn8 = 0;
8490 85 tempitem.wpn9 = 0;
8491 85 tempitem.wpn10 = 0;
8492 85 break;
8493 }
8494 case itype_key:
8495 {
8496 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8497 84 tempitem.misc1 = 0;
8498 84 tempitem.misc2 = 0;
8499 84 tempitem.misc3 = 0;
8500 84 tempitem.misc4 = 0;
8501 84 tempitem.misc5 = 0;
8502 84 tempitem.misc6 = 0;
8503 84 tempitem.misc7 = 0;
8504 84 tempitem.misc8 = 0;
8505 84 tempitem.misc9 = 0;
8506 84 tempitem.misc10 = 0;
8507 84 tempitem.wpn = 0;
8508 84 tempitem.wpn2 = 0;
8509 84 tempitem.wpn3 = 0;
8510 84 tempitem.wpn4 = 0;
8511 84 tempitem.wpn5 = 0;
8512 84 tempitem.wpn6 = 0;
8513 84 tempitem.wpn7 = 0;
8514 84 tempitem.wpn8 = 0;
8515 84 tempitem.wpn9 = 0;
8516 84 tempitem.wpn10 = 0;
8517 84 break;
8518 }
8519 case itype_magiccontainer:
8520 {
8521 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8522 85 tempitem.misc1 = 0;
8523 85 tempitem.misc2 = 0;
8524 85 tempitem.misc3 = 0;
8525 85 tempitem.misc4 = 0;
8526 85 tempitem.misc5 = 0;
8527 85 tempitem.misc6 = 0;
8528 85 tempitem.misc7 = 0;
8529 85 tempitem.misc8 = 0;
8530 85 tempitem.misc9 = 0;
8531 85 tempitem.misc10 = 0;
8532 85 tempitem.wpn = 0;
8533 85 tempitem.wpn2 = 0;
8534 85 tempitem.wpn3 = 0;
8535 85 tempitem.wpn4 = 0;
8536 85 tempitem.wpn5 = 0;
8537 85 tempitem.wpn6 = 0;
8538 85 tempitem.wpn7 = 0;
8539 85 tempitem.wpn8 = 0;
8540 85 tempitem.wpn9 = 0;
8541 85 tempitem.wpn10 = 0;
8542 85 break;
8543 }
8544 case itype_triforcepiece:
8545 {
8546 168 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8547 168 tempitem.misc3 = 0;
8548 168 tempitem.misc4 = 0;
8549 168 tempitem.misc5 = 0;
8550 168 tempitem.misc6 = 0;
8551 168 tempitem.misc7 = 0;
8552 168 tempitem.misc8 = 0;
8553 168 tempitem.misc9 = 0;
8554 168 tempitem.misc10 = 0;
8555 168 tempitem.wpn = 0;
8556 168 tempitem.wpn2 = 0;
8557 168 tempitem.wpn3 = 0;
8558 168 tempitem.wpn4 = 0;
8559 168 tempitem.wpn5 = 0;
8560 168 tempitem.wpn6 = 0;
8561 168 tempitem.wpn7 = 0;
8562 168 tempitem.wpn8 = 0;
8563 168 tempitem.wpn9 = 0;
8564 168 tempitem.wpn10 = 0;
8565 168 break;
8566 }
8567 case itype_map: case itype_compass: case itype_bosskey:
8568 {
8569 253 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8570 253 tempitem.misc1 = 0;
8571 253 tempitem.misc2 = 0;
8572 253 tempitem.misc3 = 0;
8573 253 tempitem.misc4 = 0;
8574 253 tempitem.misc5 = 0;
8575 253 tempitem.misc6 = 0;
8576 253 tempitem.misc7 = 0;
8577 253 tempitem.misc8 = 0;
8578 253 tempitem.misc9 = 0;
8579 253 tempitem.misc10 = 0;
8580 253 tempitem.wpn = 0;
8581 253 tempitem.wpn2 = 0;
8582 253 tempitem.wpn3 = 0;
8583 253 tempitem.wpn4 = 0;
8584 253 tempitem.wpn5 = 0;
8585 253 tempitem.wpn6 = 0;
8586 253 tempitem.wpn7 = 0;
8587 253 tempitem.wpn8 = 0;
8588 253 tempitem.wpn9 = 0;
8589 253 tempitem.wpn10 = 0;
8590 253 break;
8591 }
8592 case itype_quiver:
8593 {
8594 336 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8595 336 tempitem.misc3 = 0;
8596 336 tempitem.misc4 = 0;
8597 336 tempitem.misc5 = 0;
8598 336 tempitem.misc6 = 0;
8599 336 tempitem.misc7 = 0;
8600 336 tempitem.misc8 = 0;
8601 336 tempitem.misc9 = 0;
8602 336 tempitem.misc10 = 0;
8603 336 tempitem.wpn = 0;
8604 336 tempitem.wpn2 = 0;
8605 336 tempitem.wpn3 = 0;
8606 336 tempitem.wpn4 = 0;
8607 336 tempitem.wpn5 = 0;
8608 336 tempitem.wpn6 = 0;
8609 336 tempitem.wpn7 = 0;
8610 336 tempitem.wpn8 = 0;
8611 336 tempitem.wpn9 = 0;
8612 336 tempitem.wpn10 = 0;
8613 336 break;
8614 }
8615 case itype_lkey:
8616 {
8617 86 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8618 86 tempitem.misc1 = 0;
8619 86 tempitem.misc2 = 0;
8620 86 tempitem.misc3 = 0;
8621 86 tempitem.misc4 = 0;
8622 86 tempitem.misc5 = 0;
8623 86 tempitem.misc6 = 0;
8624 86 tempitem.misc7 = 0;
8625 86 tempitem.misc8 = 0;
8626 86 tempitem.misc9 = 0;
8627 86 tempitem.misc10 = 0;
8628 86 tempitem.wpn = 0;
8629 86 tempitem.wpn2 = 0;
8630 86 tempitem.wpn3 = 0;
8631 86 tempitem.wpn4 = 0;
8632 86 tempitem.wpn5 = 0;
8633 86 tempitem.wpn6 = 0;
8634 86 tempitem.wpn7 = 0;
8635 86 tempitem.wpn8 = 0;
8636 86 tempitem.wpn9 = 0;
8637 86 tempitem.wpn10 = 0;
8638 86 break;
8639 }
8640 case itype_cbyrna:
8641 {
8642 84 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8643 84 tempitem.misc4 = 0;
8644 84 tempitem.misc5 = 0;
8645 84 tempitem.misc6 = 0;
8646 84 tempitem.misc7 = 0;
8647 84 tempitem.misc8 = 0;
8648 84 tempitem.misc9 = 0;
8649 84 tempitem.misc10 = 0;
8650 84 tempitem.wpn6 = 0;
8651 84 tempitem.wpn7 = 0;
8652 84 tempitem.wpn8 = 0;
8653 84 tempitem.wpn9 = 0;
8654 84 tempitem.wpn10 = 0;
8655 84 break;
8656 }
8657 case itype_rupee: case itype_arrowammo:
8658 {
8659 1047 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8660 1047 tempitem.misc1 = 0;
8661 1047 tempitem.misc2 = 0;
8662 1047 tempitem.misc3 = 0;
8663 1047 tempitem.misc4 = 0;
8664 1047 tempitem.misc5 = 0;
8665 1047 tempitem.misc6 = 0;
8666 1047 tempitem.misc7 = 0;
8667 1047 tempitem.misc8 = 0;
8668 1047 tempitem.misc9 = 0;
8669 1047 tempitem.misc10 = 0;
8670 1047 tempitem.wpn = 0;
8671 1047 tempitem.wpn2 = 0;
8672 1047 tempitem.wpn3 = 0;
8673 1047 tempitem.wpn4 = 0;
8674 1047 tempitem.wpn5 = 0;
8675 1047 tempitem.wpn6 = 0;
8676 1047 tempitem.wpn7 = 0;
8677 1047 tempitem.wpn8 = 0;
8678 1047 tempitem.wpn9 = 0;
8679 1047 tempitem.wpn10 = 0;
8680 1047 break;
8681 }
8682 case itype_fairy:
8683 {
8684 152 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8685 152 tempitem.misc4 = 0;
8686 152 tempitem.misc5 = 0;
8687 152 tempitem.misc6 = 0;
8688 152 tempitem.misc7 = 0;
8689 152 tempitem.misc8 = 0;
8690 152 tempitem.misc9 = 0;
8691 152 tempitem.misc10 = 0;
8692 152 tempitem.wpn = 0;
8693 152 tempitem.wpn2 = 0;
8694 152 tempitem.wpn3 = 0;
8695 152 tempitem.wpn4 = 0;
8696 152 tempitem.wpn5 = 0;
8697 152 tempitem.wpn6 = 0;
8698 152 tempitem.wpn7 = 0;
8699 152 tempitem.wpn8 = 0;
8700 152 tempitem.wpn9 = 0;
8701 152 tempitem.wpn10 = 0;
8702 152 break;
8703 }
8704 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8705 {
8706 903 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8707 903 tempitem.misc1 = 0;
8708 903 tempitem.misc2 = 0;
8709 903 tempitem.misc3 = 0;
8710 903 tempitem.misc4 = 0;
8711 903 tempitem.misc5 = 0;
8712 903 tempitem.misc6 = 0;
8713 903 tempitem.misc7 = 0;
8714 903 tempitem.misc8 = 0;
8715 903 tempitem.misc9 = 0;
8716 903 tempitem.misc10 = 0;
8717 903 tempitem.wpn = 0;
8718 903 tempitem.wpn2 = 0;
8719 903 tempitem.wpn3 = 0;
8720 903 tempitem.wpn4 = 0;
8721 903 tempitem.wpn5 = 0;
8722 903 tempitem.wpn6 = 0;
8723 903 tempitem.wpn7 = 0;
8724 903 tempitem.wpn8 = 0;
8725 903 tempitem.wpn9 = 0;
8726 903 tempitem.wpn10 = 0;
8727 903 break;
8728 }
8729 case itype_bombbag:
8730 {
8731 336 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8732 336 tempitem.misc3 = 0;
8733 336 tempitem.misc4 = 0;
8734 336 tempitem.misc5 = 0;
8735 336 tempitem.misc6 = 0;
8736 336 tempitem.misc7 = 0;
8737 336 tempitem.misc8 = 0;
8738 336 tempitem.misc9 = 0;
8739 336 tempitem.misc10 = 0;
8740 336 tempitem.wpn = 0;
8741 336 tempitem.wpn2 = 0;
8742 336 tempitem.wpn3 = 0;
8743 336 tempitem.wpn4 = 0;
8744 336 tempitem.wpn5 = 0;
8745 336 tempitem.wpn6 = 0;
8746 336 tempitem.wpn7 = 0;
8747 336 tempitem.wpn8 = 0;
8748 336 tempitem.wpn9 = 0;
8749 336 tempitem.wpn10 = 0;
8750 336 break;
8751 }
8752 case itype_rocs:
8753 {
8754 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8755 84 tempitem.misc1 = 0;
8756 84 tempitem.misc2 = 0;
8757 84 tempitem.misc3 = 0;
8758 84 tempitem.misc4 = 0;
8759 84 tempitem.misc5 = 0;
8760 84 tempitem.misc6 = 0;
8761 84 tempitem.misc7 = 0;
8762 84 tempitem.misc8 = 0;
8763 84 tempitem.misc9 = 0;
8764 84 tempitem.misc10 = 0;
8765 84 tempitem.wpn = 0;
8766 84 tempitem.wpn2 = 0;
8767 84 tempitem.wpn3 = 0;
8768 84 tempitem.wpn4 = 0;
8769 84 tempitem.wpn5 = 0;
8770 84 tempitem.wpn6 = 0;
8771 84 tempitem.wpn7 = 0;
8772 84 tempitem.wpn8 = 0;
8773 84 tempitem.wpn9 = 0;
8774 84 tempitem.wpn10 = 0;
8775 84 break;
8776 }
8777 case itype_hoverboots:
8778 {
8779 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8780 84 tempitem.misc2 = 0;
8781 84 tempitem.misc3 = 0;
8782 84 tempitem.misc4 = 0;
8783 84 tempitem.misc5 = 0;
8784 84 tempitem.misc6 = 0;
8785 84 tempitem.misc7 = 0;
8786 84 tempitem.misc8 = 0;
8787 84 tempitem.misc9 = 0;
8788 84 tempitem.misc10 = 0;
8789 84 tempitem.wpn2 = 0;
8790 84 tempitem.wpn3 = 0;
8791 84 tempitem.wpn4 = 0;
8792 84 tempitem.wpn5 = 0;
8793 84 tempitem.wpn6 = 0;
8794 84 tempitem.wpn7 = 0;
8795 84 tempitem.wpn8 = 0;
8796 84 tempitem.wpn9 = 0;
8797 84 tempitem.wpn10 = 0;
8798 84 break;
8799 }
8800 case itype_spinscroll:
8801 {
8802 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8803 84 tempitem.misc2 = 0;
8804 84 tempitem.misc3 = 0;
8805 84 tempitem.misc4 = 0;
8806 84 tempitem.misc5 = 0;
8807 84 tempitem.misc6 = 0;
8808 84 tempitem.misc7 = 0;
8809 84 tempitem.misc8 = 0;
8810 84 tempitem.misc9 = 0;
8811 84 tempitem.misc10 = 0;
8812 84 tempitem.wpn = 0;
8813 84 tempitem.wpn2 = 0;
8814 84 tempitem.wpn3 = 0;
8815 84 tempitem.wpn4 = 0;
8816 84 tempitem.wpn5 = 0;
8817 84 tempitem.wpn6 = 0;
8818 84 tempitem.wpn7 = 0;
8819 84 tempitem.wpn8 = 0;
8820 84 tempitem.wpn9 = 0;
8821 84 tempitem.wpn10 = 0;
8822 84 break;
8823 }
8824 case itype_crossscroll:
8825 {
8826 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8827 84 tempitem.misc1 = 0;
8828 84 tempitem.misc2 = 0;
8829 84 tempitem.misc3 = 0;
8830 84 tempitem.misc4 = 0;
8831 84 tempitem.misc5 = 0;
8832 84 tempitem.misc6 = 0;
8833 84 tempitem.misc7 = 0;
8834 84 tempitem.misc8 = 0;
8835 84 tempitem.misc9 = 0;
8836 84 tempitem.misc10 = 0;
8837 84 tempitem.wpn = 0;
8838 84 tempitem.wpn2 = 0;
8839 84 tempitem.wpn3 = 0;
8840 84 tempitem.wpn4 = 0;
8841 84 tempitem.wpn5 = 0;
8842 84 tempitem.wpn6 = 0;
8843 84 tempitem.wpn7 = 0;
8844 84 tempitem.wpn8 = 0;
8845 84 tempitem.wpn9 = 0;
8846 84 tempitem.wpn10 = 0;
8847 84 break;
8848 }
8849 case itype_quakescroll:
8850 {
8851 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8852 84 tempitem.misc3 = 0;
8853 84 tempitem.misc4 = 0;
8854 84 tempitem.misc5 = 0;
8855 84 tempitem.misc6 = 0;
8856 84 tempitem.misc7 = 0;
8857 84 tempitem.misc8 = 0;
8858 84 tempitem.misc9 = 0;
8859 84 tempitem.misc10 = 0;
8860 84 tempitem.wpn = 0;
8861 84 tempitem.wpn2 = 0;
8862 84 tempitem.wpn3 = 0;
8863 84 tempitem.wpn4 = 0;
8864 84 tempitem.wpn5 = 0;
8865 84 tempitem.wpn6 = 0;
8866 84 tempitem.wpn7 = 0;
8867 84 tempitem.wpn8 = 0;
8868 84 tempitem.wpn9 = 0;
8869 84 tempitem.wpn10 = 0;
8870 84 break;
8871 }
8872 case itype_whispring:
8873 {
8874 169 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8875 169 tempitem.misc2 = 0;
8876 169 tempitem.misc3 = 0;
8877 169 tempitem.misc4 = 0;
8878 169 tempitem.misc5 = 0;
8879 169 tempitem.misc6 = 0;
8880 169 tempitem.misc7 = 0;
8881 169 tempitem.misc8 = 0;
8882 169 tempitem.misc9 = 0;
8883 169 tempitem.misc10 = 0;
8884 169 tempitem.wpn = 0;
8885 169 tempitem.wpn2 = 0;
8886 169 tempitem.wpn3 = 0;
8887 169 tempitem.wpn4 = 0;
8888 169 tempitem.wpn5 = 0;
8889 169 tempitem.wpn6 = 0;
8890 169 tempitem.wpn7 = 0;
8891 169 tempitem.wpn8 = 0;
8892 169 tempitem.wpn9 = 0;
8893 169 tempitem.wpn10 = 0;
8894 169 break;
8895 }
8896 case itype_chargering:
8897 {
8898 168 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8899 168 tempitem.misc3 = 0;
8900 168 tempitem.misc4 = 0;
8901 168 tempitem.misc5 = 0;
8902 168 tempitem.misc6 = 0;
8903 168 tempitem.misc7 = 0;
8904 168 tempitem.misc8 = 0;
8905 168 tempitem.misc9 = 0;
8906 168 tempitem.misc10 = 0;
8907 168 tempitem.wpn = 0;
8908 168 tempitem.wpn2 = 0;
8909 168 tempitem.wpn3 = 0;
8910 168 tempitem.wpn4 = 0;
8911 168 tempitem.wpn5 = 0;
8912 168 tempitem.wpn6 = 0;
8913 168 tempitem.wpn7 = 0;
8914 168 tempitem.wpn8 = 0;
8915 168 tempitem.wpn9 = 0;
8916 168 tempitem.wpn10 = 0;
8917 168 break;
8918 }
8919 case itype_perilscroll:
8920 {
8921 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8922 84 tempitem.misc2 = 0;
8923 84 tempitem.misc3 = 0;
8924 84 tempitem.misc4 = 0;
8925 84 tempitem.misc5 = 0;
8926 84 tempitem.misc6 = 0;
8927 84 tempitem.misc7 = 0;
8928 84 tempitem.misc8 = 0;
8929 84 tempitem.misc9 = 0;
8930 84 tempitem.misc10 = 0;
8931 84 tempitem.wpn = 0;
8932 84 tempitem.wpn2 = 0;
8933 84 tempitem.wpn3 = 0;
8934 84 tempitem.wpn4 = 0;
8935 84 tempitem.wpn5 = 0;
8936 84 tempitem.wpn6 = 0;
8937 84 tempitem.wpn7 = 0;
8938 84 tempitem.wpn8 = 0;
8939 84 tempitem.wpn9 = 0;
8940 84 tempitem.wpn10 = 0;
8941 84 break;
8942 }
8943 case itype_wealthmedal:
8944 {
8945 253 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8946 253 tempitem.misc2 = 0;
8947 253 tempitem.misc3 = 0;
8948 253 tempitem.misc4 = 0;
8949 253 tempitem.misc5 = 0;
8950 253 tempitem.misc6 = 0;
8951 253 tempitem.misc7 = 0;
8952 253 tempitem.misc8 = 0;
8953 253 tempitem.misc9 = 0;
8954 253 tempitem.misc10 = 0;
8955 253 tempitem.wpn = 0;
8956 253 tempitem.wpn2 = 0;
8957 253 tempitem.wpn3 = 0;
8958 253 tempitem.wpn4 = 0;
8959 253 tempitem.wpn5 = 0;
8960 253 tempitem.wpn6 = 0;
8961 253 tempitem.wpn7 = 0;
8962 253 tempitem.wpn8 = 0;
8963 253 tempitem.wpn9 = 0;
8964 253 tempitem.wpn10 = 0;
8965 253 break;
8966 }
8967 case itype_heartring:
8968 {
8969 254 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8970 254 tempitem.misc3 = 0;
8971 254 tempitem.misc4 = 0;
8972 254 tempitem.misc5 = 0;
8973 254 tempitem.misc6 = 0;
8974 254 tempitem.misc7 = 0;
8975 254 tempitem.misc8 = 0;
8976 254 tempitem.misc9 = 0;
8977 254 tempitem.misc10 = 0;
8978 254 tempitem.wpn = 0;
8979 254 tempitem.wpn2 = 0;
8980 254 tempitem.wpn3 = 0;
8981 254 tempitem.wpn4 = 0;
8982 254 tempitem.wpn5 = 0;
8983 254 tempitem.wpn6 = 0;
8984 254 tempitem.wpn7 = 0;
8985 254 tempitem.wpn8 = 0;
8986 254 tempitem.wpn9 = 0;
8987 254 tempitem.wpn10 = 0;
8988 254 break;
8989 }
8990 case itype_magicring:
8991 {
8992 340 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8993 340 tempitem.misc3 = 0;
8994 340 tempitem.misc4 = 0;
8995 340 tempitem.misc5 = 0;
8996 340 tempitem.misc6 = 0;
8997 340 tempitem.misc7 = 0;
8998 340 tempitem.misc8 = 0;
8999 340 tempitem.misc9 = 0;
9000 340 tempitem.misc10 = 0;
9001 340 tempitem.wpn = 0;
9002 340 tempitem.wpn2 = 0;
9003 340 tempitem.wpn3 = 0;
9004 340 tempitem.wpn4 = 0;
9005 340 tempitem.wpn5 = 0;
9006 340 tempitem.wpn6 = 0;
9007 340 tempitem.wpn7 = 0;
9008 340 tempitem.wpn8 = 0;
9009 340 tempitem.wpn9 = 0;
9010 340 tempitem.wpn10 = 0;
9011 340 break;
9012 }
9013 case itype_spinscroll2:
9014 {
9015 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9016 84 tempitem.misc2 = 0;
9017 84 tempitem.misc3 = 0;
9018 84 tempitem.misc4 = 0;
9019 84 tempitem.misc5 = 0;
9020 84 tempitem.misc6 = 0;
9021 84 tempitem.misc7 = 0;
9022 84 tempitem.misc8 = 0;
9023 84 tempitem.misc9 = 0;
9024 84 tempitem.misc10 = 0;
9025 84 tempitem.wpn = 0;
9026 84 tempitem.wpn2 = 0;
9027 84 tempitem.wpn3 = 0;
9028 84 tempitem.wpn4 = 0;
9029 84 tempitem.wpn5 = 0;
9030 84 tempitem.wpn6 = 0;
9031 84 tempitem.wpn7 = 0;
9032 84 tempitem.wpn8 = 0;
9033 84 tempitem.wpn9 = 0;
9034 84 tempitem.wpn10 = 0;
9035 84 break;
9036 }
9037 case itype_quakescroll2:
9038 {
9039 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9040 84 tempitem.misc3 = 0;
9041 84 tempitem.misc4 = 0;
9042 84 tempitem.misc5 = 0;
9043 84 tempitem.misc6 = 0;
9044 84 tempitem.misc7 = 0;
9045 84 tempitem.misc8 = 0;
9046 84 tempitem.misc9 = 0;
9047 84 tempitem.misc10 = 0;
9048 84 tempitem.wpn = 0;
9049 84 tempitem.wpn2 = 0;
9050 84 tempitem.wpn3 = 0;
9051 84 tempitem.wpn4 = 0;
9052 84 tempitem.wpn5 = 0;
9053 84 tempitem.wpn6 = 0;
9054 84 tempitem.wpn7 = 0;
9055 84 tempitem.wpn8 = 0;
9056 84 tempitem.wpn9 = 0;
9057 84 tempitem.wpn10 = 0;
9058 84 break;
9059 }
9060 case itype_agony:
9061 {
9062 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9063 84 tempitem.misc2 = 0;
9064 84 tempitem.misc3 = 0;
9065 84 tempitem.misc4 = 0;
9066 84 tempitem.misc5 = 0;
9067 84 tempitem.misc6 = 0;
9068 84 tempitem.misc7 = 0;
9069 84 tempitem.misc8 = 0;
9070 84 tempitem.misc9 = 0;
9071 84 tempitem.misc10 = 0;
9072 84 tempitem.wpn = 0;
9073 84 tempitem.wpn2 = 0;
9074 84 tempitem.wpn3 = 0;
9075 84 tempitem.wpn4 = 0;
9076 84 tempitem.wpn5 = 0;
9077 84 tempitem.wpn6 = 0;
9078 84 tempitem.wpn7 = 0;
9079 84 tempitem.wpn8 = 0;
9080 84 tempitem.wpn9 = 0;
9081 84 tempitem.wpn10 = 0;
9082 84 break;
9083 }
9084 case itype_stompboots:
9085 {
9086 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9087 84 tempitem.misc1 = 0;
9088 84 tempitem.misc2 = 0;
9089 84 tempitem.misc3 = 0;
9090 84 tempitem.misc4 = 0;
9091 84 tempitem.misc5 = 0;
9092 84 tempitem.misc6 = 0;
9093 84 tempitem.misc7 = 0;
9094 84 tempitem.misc8 = 0;
9095 84 tempitem.misc9 = 0;
9096 84 tempitem.misc10 = 0;
9097 84 tempitem.wpn = 0;
9098 84 tempitem.wpn2 = 0;
9099 84 tempitem.wpn3 = 0;
9100 84 tempitem.wpn4 = 0;
9101 84 tempitem.wpn5 = 0;
9102 84 tempitem.wpn6 = 0;
9103 84 tempitem.wpn7 = 0;
9104 84 tempitem.wpn8 = 0;
9105 84 tempitem.wpn9 = 0;
9106 84 tempitem.wpn10 = 0;
9107 84 break;
9108 }
9109 case itype_whimsicalring:
9110 {
9111 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9112 84 tempitem.misc2 = 0;
9113 84 tempitem.misc3 = 0;
9114 84 tempitem.misc4 = 0;
9115 84 tempitem.misc5 = 0;
9116 84 tempitem.misc6 = 0;
9117 84 tempitem.misc7 = 0;
9118 84 tempitem.misc8 = 0;
9119 84 tempitem.misc9 = 0;
9120 84 tempitem.misc10 = 0;
9121 84 tempitem.wpn = 0;
9122 84 tempitem.wpn2 = 0;
9123 84 tempitem.wpn3 = 0;
9124 84 tempitem.wpn4 = 0;
9125 84 tempitem.wpn5 = 0;
9126 84 tempitem.wpn6 = 0;
9127 84 tempitem.wpn7 = 0;
9128 84 tempitem.wpn8 = 0;
9129 84 tempitem.wpn9 = 0;
9130 84 tempitem.wpn10 = 0;
9131 84 break;
9132 }
9133 case itype_perilring:
9134 {
9135 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9136 85 tempitem.misc2 = 0;
9137 85 tempitem.misc3 = 0;
9138 85 tempitem.misc4 = 0;
9139 85 tempitem.misc5 = 0;
9140 85 tempitem.misc6 = 0;
9141 85 tempitem.misc7 = 0;
9142 85 tempitem.misc8 = 0;
9143 85 tempitem.misc9 = 0;
9144 85 tempitem.misc10 = 0;
9145 85 tempitem.wpn = 0;
9146 85 tempitem.wpn2 = 0;
9147 85 tempitem.wpn3 = 0;
9148 85 tempitem.wpn4 = 0;
9149 85 tempitem.wpn5 = 0;
9150 85 tempitem.wpn6 = 0;
9151 85 tempitem.wpn7 = 0;
9152 85 tempitem.wpn8 = 0;
9153 85 tempitem.wpn9 = 0;
9154 85 tempitem.wpn10 = 0;
9155 85 break;
9156 }
9157 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9158 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9159 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9160 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9161 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9162 {
9163 2368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9164 2368 tempitem.misc1 = 0;
9165 2368 tempitem.misc2 = 0;
9166 2368 tempitem.misc3 = 0;
9167 2368 tempitem.misc4 = 0;
9168 2368 tempitem.misc5 = 0;
9169 2368 tempitem.misc6 = 0;
9170 2368 tempitem.misc7 = 0;
9171 2368 tempitem.misc8 = 0;
9172 2368 tempitem.misc9 = 0;
9173 2368 tempitem.misc10 = 0;
9174 2368 tempitem.wpn = 0;
9175 2368 tempitem.wpn2 = 0;
9176 2368 tempitem.wpn3 = 0;
9177 2368 tempitem.wpn4 = 0;
9178 2368 tempitem.wpn5 = 0;
9179 2368 tempitem.wpn6 = 0;
9180 2368 tempitem.wpn7 = 0;
9181 2368 tempitem.wpn8 = 0;
9182 2368 tempitem.wpn9 = 0;
9183 2368 tempitem.wpn10 = 0;
9184 2368 break;
9185 }
9186 }
9187 21760 }
9188 //Port quest rules to items
9189
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version <= 31)
9190 {
9191
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 21661 times.
21760 if(tempitem.family == itype_bomb)
9192 {
9193
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 10 times.
99 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9194 89 else tempitem.flags &= ~ ITEM_FLAG2;
9195 99 }
9196
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 21577 times.
21661 else if(tempitem.family == itype_sbomb)
9197 {
9198
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 74 times.
84 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9199 74 else tempitem.flags &= ~ ITEM_FLAG2;
9200 84 }
9201
9202
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 21324 times.
21577 else if(tempitem.family == itype_brang)
9203 {
9204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
253 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9205 253 else tempitem.flags &= ~ ITEM_FLAG4;
9206 253 }
9207
2/2
✓ Branch 0 taken 21225 times.
✓ Branch 1 taken 99 times.
21324 else if(tempitem.family == itype_wand)
9208 {
9209
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 97 times.
99 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9210 97 else tempitem.flags &= ~ ITEM_FLAG3;
9211 99 }
9212 21760 }
9213
9214 //Port quest rules to items
9215
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version <= 37)
9216 {
9217
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21675 times.
21760 if(tempitem.family == itype_flippers)
9218 {
9219
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9220 85 else tempitem.flags &= ~ ITEM_FLAG1;
9221 85 }
9222
2/2
✓ Branch 0 taken 14827 times.
✓ Branch 1 taken 6848 times.
21675 else if(tempitem.family == itype_sword)
9223 {
9224
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6779 times.
6848 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9225 6779 else tempitem.flags &= ~ ITEM_FLAG5;
9226 6848 }
9227
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 14728 times.
14827 else if(tempitem.family == itype_wand)
9228 {
9229
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9230 96 else tempitem.flags &= ~ ITEM_FLAG5;
9231 99 }
9232
4/4
✓ Branch 0 taken 14629 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 14423 times.
14728 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9233 {
9234 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9235
2/2
✓ Branch 0 taken 233 times.
✓ Branch 1 taken 72 times.
305 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9236 233 else tempitem.flags &= ~ ITEM_FLAG3;
9237 305 }
9238 21760 }
9239
9240
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 38)
9241 {
9242
4/4
✓ Branch 0 taken 21507 times.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 21339 times.
21760 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9243 {
9244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9245 421 else tempitem.flags &= ~ITEM_FLAG4;
9246
9247
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 410 times.
421 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9248 410 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9249 421 }
9250
2/2
✓ Branch 0 taken 21089 times.
✓ Branch 1 taken 250 times.
21339 else if(tempitem.family == itype_arrow)
9251 {
9252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250 times.
250 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9253 250 else tempitem.flags &= ~ITEM_FLAG4;
9254
9255
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 246 times.
250 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9256 246 else tempitem.flags |= ITEM_FLAG2;
9257 250 }
9258 21760 }
9259
9260
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 39)
9261 {
9262
6/6
✓ Branch 0 taken 21676 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 21577 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 206 times.
✓ Branch 5 taken 21371 times.
21760 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9263 {
9264
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 377 times.
389 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9265 377 else tempitem.flags &= ~ITEM_FLAG5;
9266 389 }
9267
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 21204 times.
21371 else if(tempitem.family == itype_potion)
9268 {
9269
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 157 times.
167 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9270 {
9271 10 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9272 10 }
9273 else
9274 {
9275 157 tempitem.flags |= ITEM_FLAG3;
9276
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 85 times.
157 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9277 72 else tempitem.flags &= ~ITEM_FLAG4;
9278 }
9279 167 }
9280
2/2
✓ Branch 0 taken 21036 times.
✓ Branch 1 taken 168 times.
21204 else if(tempitem.family == itype_triforcepiece)
9281 {
9282
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 152 times.
168 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9283 {
9284 16 tempitem.flags |= ITEM_FLAG3;
9285
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10 times.
16 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9286 10 else tempitem.flags &= ~ITEM_FLAG4;
9287 16 }
9288 else
9289 {
9290 152 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9291 }
9292 168 }
9293 21760 }
9294
9295
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 40)
9296 {
9297
4/4
✓ Branch 0 taken 21482 times.
✓ Branch 1 taken 278 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 21397 times.
21760 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9298 {
9299
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 316 times.
363 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9300 316 else tempitem.flags &= ~ITEM_FLAG1;
9301 363 }
9302
8/8
✓ Branch 0 taken 21191 times.
✓ Branch 1 taken 206 times.
✓ Branch 2 taken 14343 times.
✓ Branch 3 taken 6848 times.
✓ Branch 4 taken 14244 times.
✓ Branch 5 taken 99 times.
✓ Branch 6 taken 84 times.
✓ Branch 7 taken 14160 times.
21397 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9303 {
9304
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 7156 times.
7237 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9305 7156 else tempitem.flags &= ~ITEM_FLAG8;
9306 7237 }
9307
6/6
✓ Branch 0 taken 14912 times.
✓ Branch 1 taken 6848 times.
✓ Branch 2 taken 14813 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 85 times.
✓ Branch 5 taken 14728 times.
21760 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9308 {
9309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7032 times.
7032 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9310 7032 else tempitem.flags &= ~ITEM_FLAG7;
9311 7032 }
9312
2/2
✓ Branch 0 taken 14644 times.
✓ Branch 1 taken 84 times.
14728 else if(tempitem.family == itype_cbyrna)
9313 {
9314 84 tempitem.flags |= ITEM_FLAG7;
9315 84 }
9316 21760 }
9317
9318
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 41 )
9319 {
9320
2/2
✓ Branch 0 taken 14912 times.
✓ Branch 1 taken 6848 times.
21760 if(tempitem.family == itype_sword)
9321 {
9322
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6779 times.
6848 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9323 6779 else tempitem.flags &= ~ITEM_FLAG9;
9324
9325
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6779 times.
6848 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9326 6779 else tempitem.flags &= ~ITEM_FLAG10;
9327 6848 }
9328 21760 }
9329
9330
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 42 )
9331 {
9332
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 21661 times.
21760 if(tempitem.family == itype_wand)
9333 {
9334
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 2 times.
99 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9335 97 else tempitem.flags &= ~ITEM_FLAG3;
9336
9337 99 tempitem.flags &= ~ITEM_FLAG6;
9338 99 }
9339
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21576 times.
21661 else if(tempitem.family == itype_hammer)
9340 {
9341 85 tempitem.flags &= ~ITEM_FLAG3;
9342 85 }
9343
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 21492 times.
21576 else if(tempitem.family == itype_cbyrna)
9344 {
9345 84 tempitem.flags |= ITEM_FLAG3;
9346
9347 84 tempitem.flags &= ~ITEM_FLAG6;
9348 84 }
9349
2/2
✓ Branch 0 taken 14644 times.
✓ Branch 1 taken 6848 times.
21492 else if(tempitem.family == itype_sword)
9350 {
9351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6848 times.
6848 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9352 6848 else tempitem.flags &= ~ITEM_FLAG6;
9353 6848 }
9354 21760 }
9355
9356
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 43 )
9357 {
9358
2/2
✓ Branch 0 taken 21630 times.
✓ Branch 1 taken 130 times.
21760 if(tempitem.family == itype_whistle)
9359 {
9360
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 3 times.
130 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9361 127 else tempitem.flags &= ~ITEM_FLAG3;
9362 130 }
9363 21760 }
9364
9365
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 45 )
9366 {
9367
2/2
✓ Branch 0 taken 21675 times.
✓ Branch 1 taken 85 times.
21760 if(tempitem.family == itype_flippers)
9368 {
9369 85 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9370 85 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9371 85 }
9372 21760 }
9373
9374
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 46 )
9375 {
9376
2/2
✓ Branch 0 taken 21676 times.
✓ Branch 1 taken 84 times.
21760 if(tempitem.family == itype_raft)
9377 {
9378 84 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9379 84 }
9380 21760 }
9381
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if ( s_version < 34 ) //! set the default counter for older quests.
9382 {
9383
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 21686 times.
21760 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9384 {
9385 74 tempitem.cost_counter[0] = 1;
9386 74 }
9387 else
9388 {
9389
2/2
✓ Branch 0 taken 18870 times.
✓ Branch 1 taken 2816 times.
21686 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9390 2816 tempitem.cost_counter[0] = 4;
9391 else
9392 {
9393 18870 tempitem.cost_amount[0] = 0;
9394 18870 tempitem.cost_counter[0] = -1;
9395 }
9396 }
9397 21760 }
9398
9399
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if ( s_version < 35 ) //new Lens of Truth flags
9400 {
9401
2/2
✓ Branch 0 taken 21676 times.
✓ Branch 1 taken 84 times.
21760 if ( tempitem.family == itype_lens )
9402 {
9403
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 3 times.
84 if ( get_bit(quest_rules,qr_RAFTLENS) )
9404 {
9405 3 tempitem.flags |= ITEM_FLAG4;
9406 3 }
9407
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 45 times.
84 if ( get_bit(quest_rules,qr_LENSHINTS) )
9408 {
9409 45 tempitem.flags |= ITEM_FLAG1;
9410 45 }
9411
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 4 times.
84 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9412 {
9413 4 tempitem.flags |= ITEM_FLAG5;
9414 4 }
9415 84 }
9416 21760 }
9417
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9418 {
9419
2/2
✓ Branch 0 taken 174080 times.
✓ Branch 1 taken 21760 times.
195840 for ( int32_t q = 0; q < 8; q++ )
9420 {
9421 174080 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9422 174080 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9423 174080 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9424 174080 tempitem.sprite_initiald[q] = 0;
9425 174080 }
9426
2/2
✓ Branch 0 taken 43520 times.
✓ Branch 1 taken 21760 times.
65280 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9427 21760 tempitem.sprite_script = 0;
9428 21760 }
9429
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9430 {
9431 21760 tempitem.pickupflag = 0;
9432 21760 }
9433
9434
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 51 )
9435 {
9436
2/2
✓ Branch 0 taken 21554 times.
✓ Branch 1 taken 206 times.
21760 if( tempitem.family == itype_candle )
9437 {
9438 206 tempitem.misc4 = 50; //Step speed
9439 206 }
9440 21760 }
9441
9442
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if( s_version < 52 )
9443 {
9444
2/2
✓ Branch 0 taken 21501 times.
✓ Branch 1 taken 259 times.
21760 if( tempitem.family == itype_shield )
9445 259 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9446 21760 }
9447
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 21760 times.
29184 if(s_version < 53)
9448 {
9449
4/4
✓ Branch 0 taken 21327 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 84 times.
21760 switch(tempitem.family)
9450 {
9451 case itype_arrow:
9452 250 tempitem.cost_counter[1] = crARROWS;
9453 250 tempitem.cost_amount[1] = 1;
9454 250 break;
9455 case itype_bomb:
9456 99 tempitem.cost_counter[1] = crBOMBS;
9457 99 tempitem.cost_amount[1] = 1;
9458 99 break;
9459 case itype_sbomb:
9460 84 tempitem.cost_counter[1] = crSBOMBS;
9461 84 tempitem.cost_amount[1] = 1;
9462 84 break;
9463 default:
9464 21327 tempitem.cost_counter[1] = crNONE;
9465 21327 tempitem.cost_amount[1] = 0;
9466 21327 }
9467 21760 tempitem.magiccosttimer[1] = 0;
9468 21760 }
9469
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 23040 times.
29184 if( s_version < 54 )
9470 {
9471
2/2
✓ Branch 0 taken 22949 times.
✓ Branch 1 taken 91 times.
23040 if( tempitem.family == itype_flippers )
9472 91 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9473 23040 }
9474
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 23040 times.
29184 if(s_version < 55)
9475 {
9476
3/3
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 178 times.
✓ Branch 2 taken 22684 times.
23040 switch(tempitem.family)
9477 {
9478 case itype_spinscroll:
9479 case itype_quakescroll:
9480 178 tempitem.usesound2 = WAV_ZN1CHARGE;
9481 178 break;
9482 case itype_spinscroll2:
9483 case itype_quakescroll2:
9484 178 tempitem.usesound2 = WAV_ZN1CHARGE2;
9485 178 break;
9486 }
9487 23040 }
9488
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 23040 times.
29184 if(s_version < 56)
9489 {
9490
4/4
✓ Branch 0 taken 22629 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 218 times.
✓ Branch 3 taken 104 times.
23040 switch(tempitem.family)
9491 {
9492 case itype_divinefire:
9493
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 5 times.
89 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9494
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 80 times.
89 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9495 89 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9496 89 break;
9497 case itype_candle:
9498
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 112 times.
218 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9499 218 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9500 218 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9501 218 break;
9502 case itype_book:
9503 104 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9504 104 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9505 104 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9506 104 break;
9507 }
9508 23040 }
9509
9510
2/2
✓ Branch 0 taken 27978 times.
✓ Branch 1 taken 1206 times.
29184 if(tempitem.fam_type==0) // Always do this
9511 1206 tempitem.fam_type=1;
9512
9513 29184 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9514 29184 }
9515 114 }
9516
9517 114 return 0;
9518 114 }
9519
9520 static bool did_init_def_items = false;
9521 59127 void init_def_items()
9522 {
9523
2/2
✓ Branch 0 taken 59089 times.
✓ Branch 1 taken 38 times.
59127 if(did_init_def_items) return;
9524 38 did_init_def_items = true;
9525 38 default_items[3].cost_counter[1] = crBOMBS;
9526 38 default_items[13].cost_counter[1] = crARROWS;
9527 38 default_items[14].cost_counter[1] = crARROWS;
9528 38 default_items[48].cost_counter[1] = crSBOMBS;
9529 38 default_items[57].cost_counter[1] = crARROWS;
9530 59127 }
9531 59127 void reset_itembuf(itemdata *item, int32_t id)
9532 {
9533 59127 init_def_items();
9534
2/2
✓ Branch 0 taken 25651 times.
✓ Branch 1 taken 33476 times.
59127 if(id<iLast)
9535 {
9536 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9537 33476 word tile = item->tile;
9538 33476 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9539 33476 int32_t ltm = item->ltm;
9540
9541 33476 memcpy(item,&default_items[id],sizeof(itemdata));
9542 33476 item->tile = tile;
9543 33476 item->misc_flags = miscs;
9544 33476 item->csets = cset;
9545 33476 item->frames = frames;
9546 33476 item->speed = speed;
9547 33476 item->delay = delay;
9548 33476 item->ltm = ltm;
9549 33476 }
9550 59127 }
9551
9552 12032 void reset_itemname(int32_t id)
9553 {
9554 12032 sprintf(item_string[id],"zz%03d",id);
9555
9556
2/2
✓ Branch 0 taken 5311 times.
✓ Branch 1 taken 6721 times.
12032 if(id < iLast)
9557 6721 strcpy(item_string[id],old_item_string[id]);
9558 12032 }
9559
9560 114 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9561 {
9562 114 word weapons_to_read=MAXWPNS;
9563 int32_t dummy;
9564 byte padding;
9565 wpndata tempweapon;
9566 114 word s_version=0, s_cversion=0;
9567
9568
9569
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(Header->zelda_version < 0x186)
9570 {
9571 weapons_to_read=64;
9572 }
9573
9574
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(Header->zelda_version < 0x185)
9575 {
9576 weapons_to_read=32;
9577 }
9578
9579
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version > 0x192)
9580 {
9581 110 weapons_to_read=0;
9582
9583 //section version info
9584
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
9585 {
9586 return qe_invalid;
9587 }
9588
9589 110 FFCore.quest_format[vWeaponSprites] = s_version;
9590
9591 //al_trace("Weapons version %d\n", s_version);
9592
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_cversion,f,true))
9593 {
9594 return qe_invalid;
9595 }
9596
9597 //section size
9598
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
9599 {
9600 return qe_invalid;
9601 }
9602
9603 //finally... section data
9604
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&weapons_to_read,f,true))
9605 {
9606 return qe_invalid;
9607 }
9608 110 }
9609
9610
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version>2)
9611 {
9612
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i=0; i<weapons_to_read; i++)
9613 {
9614 char tempname[64];
9615
9616
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(!pfread(tempname, 64, f, keepdata))
9617 {
9618 return qe_invalid;
9619 }
9620
9621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26880 times.
26880 if(keepdata)
9622 {
9623 26880 strcpy(weapon_string[i], tempname);
9624 26880 }
9625 26880 }
9626
9627
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(s_version<4)
9628 {
9629 if(keepdata)
9630 {
9631 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9632 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9633 }
9634 }
9635
9636
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(s_version<5)
9637 {
9638 if(keepdata)
9639 {
9640 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9641 }
9642 }
9643
9644 /*
9645 if (s_version<6)
9646 {
9647 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9648 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9649 }
9650 */
9651 105 }
9652 else
9653 {
9654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
9655
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<WPNCNT; i++)
9656 2313 reset_weaponname(i);
9657 }
9658
9659
2/2
✓ Branch 0 taken 28244 times.
✓ Branch 1 taken 114 times.
28358 for(int32_t i=0; i<weapons_to_read; i++)
9660 {
9661 28244 word oldtile = 0;
9662
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 21332 times.
28244 if (s_version < 8)
9663 {
9664
1/2
✓ Branch 0 taken 21332 times.
✗ Branch 1 not taken.
21332 if (!p_igetw(&oldtile, f, true))
9665 return qe_invalid;
9666 21332 }
9667
9668
1/2
✓ Branch 0 taken 28244 times.
✗ Branch 1 not taken.
28244 if(!p_getc(&tempweapon.misc,f,true))
9669 {
9670 return qe_invalid;
9671 }
9672
9673
1/2
✓ Branch 0 taken 28244 times.
✗ Branch 1 not taken.
28244 if(!p_getc(&tempweapon.csets,f,true))
9674 {
9675 return qe_invalid;
9676 }
9677
9678
1/2
✓ Branch 0 taken 28244 times.
✗ Branch 1 not taken.
28244 if(!p_getc(&tempweapon.frames,f,true))
9679 {
9680 return qe_invalid;
9681 }
9682
9683
1/2
✓ Branch 0 taken 28244 times.
✗ Branch 1 not taken.
28244 if(!p_getc(&tempweapon.speed,f,true))
9684 {
9685 return qe_invalid;
9686 }
9687
9688
1/2
✓ Branch 0 taken 28244 times.
✗ Branch 1 not taken.
28244 if(!p_getc(&tempweapon.type,f,true))
9689 {
9690 return qe_invalid;
9691 }
9692
9693
2/2
✓ Branch 0 taken 20820 times.
✓ Branch 1 taken 7424 times.
28244 if ( s_version >= 7 )
9694 {
9695
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetw(&tempweapon.script,f,true))
9696 {
9697 return qe_invalid;
9698 }
9699
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(!p_igetl(&tempweapon.tile,f,true))
9700 {
9701 return qe_invalid;
9702 }
9703 7424 }
9704
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 20820 times.
28244 if ( s_version < 7 )
9705 {
9706 20820 tempweapon.tile = oldtile;
9707 20820 }
9708
9709
2/2
✓ Branch 0 taken 27220 times.
✓ Branch 1 taken 1024 times.
28244 if(Header->zelda_version < 0x193)
9710 {
9711
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f,true))
9712 {
9713 return qe_invalid;
9714 }
9715 1024 }
9716
9717
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 1364 times.
28244 if(s_version < 6)
9718 {
9719
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1360 times.
1364 if(i==ewFIRETRAIL)
9720 {
9721 4 tempweapon.misc |= WF_BEHIND;
9722 4 }
9723 else
9724 1360 tempweapon.misc &= ~WF_BEHIND;
9725 1364 }
9726
9727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28244 times.
28244 if(keepdata==true)
9728 {
9729 28244 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9730 28244 }
9731 28244 }
9732
9733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
9734 {
9735
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<2)
9736 {
9737 9 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9738 9 }
9739
9740
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version<5)
9741 {
9742 9 wpnsbuf[iwQuarterHearts].tile=1;
9743 9 wpnsbuf[iwQuarterHearts].csets=1;
9744 9 }
9745
9746
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(Header->zelda_version < 0x176)
9747 {
9748 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9749 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9750 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9751 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9752 }
9753
9754
2/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if((Header->zelda_version < 0x192)||
9755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9756 {
9757 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9758 4 }
9759
9760
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if((Header->zelda_version < 0x210))
9761 {
9762 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9763 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9764 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9765 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9766 4 }
9767 114 }
9768
9769 114 return 0;
9770 114 }
9771
9772 114 void init_guys(int32_t guyversion)
9773 {
9774
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<MAXGUYS; i++)
9775 {
9776 58368 guysbuf[i] = default_guys[0];
9777 58368 }
9778
9779
2/2
✓ Branch 0 taken 20178 times.
✓ Branch 1 taken 114 times.
20292 for(int32_t i=0; i<OLDMAXGUYS; i++)
9780 {
9781 20178 guysbuf[i] = default_guys[i];
9782
2/2
✓ Branch 0 taken 19950 times.
✓ Branch 1 taken 228 times.
20178 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9783 20178 guysbuf[i].spr_death = iwDeath;
9784 20178 guysbuf[i].spr_spawn = iwSpawn;
9785 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9786
4/4
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 18585 times.
✓ Branch 2 taken 1584 times.
✓ Branch 3 taken 9 times.
20178 if(guyversion<=3 && i==ePATRABS)
9787 {
9788 9 guysbuf[i].bosspal=spDIG;
9789 9 guysbuf[i].cset=14;
9790 9 guysbuf[i].misc9=14;
9791 9 }
9792
9793
2/2
✓ Branch 0 taken 18585 times.
✓ Branch 1 taken 1593 times.
20178 if(guyversion<=3)
9794 {
9795 // Rope/Ghini Flash rules
9796
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 885 times.
1593 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9797 {
9798
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 5 times.
885 if(i==eROPE2)
9799 {
9800 5 guysbuf[i].flags2 &= ~guy_flashing;
9801 5 }
9802 885 }
9803
9804
2/2
✓ Branch 0 taken 1062 times.
✓ Branch 1 taken 531 times.
1593 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9805 {
9806
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9807 {
9808 18 guysbuf[i].flags2 &= ~guy_flashing;
9809 18 }
9810 531 }
9811
9812
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 9 times.
1593 if(i==eGHINI2)
9813 {
9814
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9815 {
9816 3 guysbuf[i].flags2 |= guy_blinking;
9817 3 }
9818
9819
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9820 {
9821 guysbuf[i].flags2 |= guy_transparent;
9822 }
9823 9 }
9824 1593 }
9825
9826 // Darknut fix
9827
10/10
✓ Branch 0 taken 20064 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 19950 times.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 19836 times.
✓ Branch 5 taken 114 times.
✓ Branch 6 taken 19722 times.
✓ Branch 7 taken 114 times.
✓ Branch 8 taken 114 times.
✓ Branch 9 taken 19608 times.
20178 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9828 {
9829
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 205 times.
570 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9830 {
9831 365 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9832 365 guysbuf[i].s_width=guysbuf[i].e_width;
9833 365 guysbuf[i].s_height=guysbuf[i].e_height;
9834 365 }
9835 205 else guysbuf[i].s_tile=860;
9836
9837
2/2
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 35 times.
570 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9838 {
9839 35 guysbuf[i].flags |= guy_bkshield;
9840 35 }
9841 570 }
9842
9843
4/4
✓ Branch 0 taken 20064 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 20170 times.
✓ Branch 3 taken 8 times.
20178 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9844 {
9845 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9846 8 }
9847 20178 }
9848 114 }
9849
9850 2304 void reset_weaponname(int32_t i)
9851 {
9852
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 1512 times.
2304 if(i<wLast)
9853 {
9854 792 strcpy(weapon_string[i],old_weapon_string[i]);
9855 792 }
9856 else
9857 1512 sprintf(weapon_string[i],"zz%03d",i);
9858 2304 }
9859
9860 114 void init_item_drop_sets()
9861 {
9862
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9863 {
9864 // item_drop_sets[i] = default_item_drop_sets[0];
9865 29184 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9866 29184 }
9867
9868
2/2
✓ Branch 0 taken 1482 times.
✓ Branch 1 taken 114 times.
1596 for(int32_t i=0; i<isMAX; i++)
9869 {
9870 1482 item_drop_sets[i] = default_item_drop_sets[i];
9871
9872 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9873
2/2
✓ Branch 0 taken 14820 times.
✓ Branch 1 taken 1482 times.
16302 for(int32_t j=0; j<10; ++j)
9874 {
9875 14820 int32_t it = item_drop_sets[i].item[j];
9876
9877
3/4
✓ Branch 0 taken 10396 times.
✓ Branch 1 taken 4424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 666 times.
14820 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9878
2/2
✓ Branch 0 taken 666 times.
✓ Branch 1 taken 9730 times.
10396 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9879 {
9880 666 item_drop_sets[i].chance[j+1]=0;
9881 666 }
9882
3/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 13698 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 456 times.
14154 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9883 {
9884 item_drop_sets[i].chance[j+1]=0;
9885 }
9886
9887 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9888
2/2
✓ Branch 0 taken 14812 times.
✓ Branch 1 taken 8 times.
14820 if(itemsbuf[it].family == itype_misc)
9889 {
9890 // If a non-gameplay item was selected, then item drop was aborted.
9891 // Reflect this by increasing the 'Nothing' chance accordingly.
9892 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9893 8 item_drop_sets[i].chance[j+1]=0;
9894 8 }
9895 14820 }
9896 1482 }
9897 114 }
9898
9899 110 void init_favorites()
9900 {
9901
2/2
✓ Branch 0 taken 33000 times.
✓ Branch 1 taken 110 times.
33110 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9902 {
9903 33000 favorite_combos[i]=-1;
9904 33000 }
9905
9906
2/2
✓ Branch 0 taken 33000 times.
✓ Branch 1 taken 110 times.
33110 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9907 {
9908 33000 favorite_comboaliases[i]=-1;
9909 33000 }
9910 110 }
9911
9912 const char *ctype_name[cMAX]=
9913 {
9914 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9915 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9916 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9917 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9918 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9919 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9920 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9921 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9922 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9923 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9924 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9925 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9926 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9927 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9928 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9929 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9930 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9931 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9932 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9933 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9934 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9935 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9936 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9937 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9938 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9939 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9940 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9941 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9942
9943 };
9944
9945 201 int32_t init_combo_classes()
9946 {
9947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201 times.
201 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9948
2/2
✓ Branch 0 taken 36381 times.
✓ Branch 1 taken 201 times.
36582 for(int32_t i=0; i<cMAX; i++)
9949 {
9950 36381 combo_class_buf[i] = default_combo_classes[i];
9951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36381 times.
36381 if ( char const* nm = zi->getComboTypeName(i) )
9952 {
9953 36381 size_t len = strlen(nm);
9954
2/2
✓ Branch 0 taken 2328384 times.
✓ Branch 1 taken 36381 times.
2364765 for ( size_t q = 0; q < 64; q++ )
9955 {
9956
2/2
✓ Branch 0 taken 537675 times.
✓ Branch 1 taken 1790709 times.
2328384 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9957 2328384 }
9958 36381 }
9959 36381 }
9960
9961 201 return 0;
9962 }
9963
9964 89 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
9965 {
9966
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 assert(v_herosprites < 6);
9967 //these are here to bypass compiler warnings about unused arguments
9968 89 cv_herosprites=cv_herosprites;
9969
9970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(keepdata)
9971 {
9972 89 zinit.hero_swim_speed=67; //default
9973 89 setupherotiles(zinit.heroAnimationStyle);
9974 89 setupherodefenses();
9975 89 setupherooffsets();
9976 89 }
9977
9978
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 76 times.
89 if(v_herosprites>=0)
9979 {
9980 word tile, tile2;
9981 byte flip, extend, dummy_byte;
9982
9983
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
9984 {
9985
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
9986 {
9987 return qe_invalid;
9988 }
9989
9990
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
9991 {
9992 return qe_invalid;
9993 }
9994
9995
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
9996 {
9997 return qe_invalid;
9998 }
9999
10000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10001 {
10002 304 walkspr[i][spr_tile]=(int32_t)tile;
10003 304 walkspr[i][spr_flip]=(int32_t)flip;
10004 304 walkspr[i][spr_extend]=(int32_t)extend;
10005 304 }
10006 304 }
10007
10008
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10009 {
10010
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10011 {
10012 return qe_invalid;
10013 }
10014
10015
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10016 {
10017 return qe_invalid;
10018 }
10019
10020
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10021 {
10022 return qe_invalid;
10023 }
10024
10025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10026 {
10027 304 stabspr[i][spr_tile]=(int32_t)tile;
10028 304 stabspr[i][spr_flip]=(int32_t)flip;
10029 304 stabspr[i][spr_extend]=(int32_t)extend;
10030 304 }
10031 304 }
10032
10033
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10034 {
10035
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10036 {
10037 return qe_invalid;
10038 }
10039
10040
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10041 {
10042 return qe_invalid;
10043 }
10044
10045
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10046 {
10047 return qe_invalid;
10048 }
10049
10050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10051 {
10052 304 slashspr[i][spr_tile]=(int32_t)tile;
10053 304 slashspr[i][spr_flip]=(int32_t)flip;
10054 304 slashspr[i][spr_extend]=(int32_t)extend;
10055 304 }
10056 304 }
10057
10058
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10059 {
10060
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10061 {
10062 return qe_invalid;
10063 }
10064
10065
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10066 {
10067 return qe_invalid;
10068 }
10069
10070
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10071 {
10072 return qe_invalid;
10073 }
10074
10075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10076 {
10077 304 floatspr[i][spr_tile]=(int32_t)tile;
10078 304 floatspr[i][spr_flip]=(int32_t)flip;
10079 304 floatspr[i][spr_extend]=(int32_t)extend;
10080 304 }
10081 304 }
10082
10083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>1)
10084 {
10085
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10086 {
10087
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10088 {
10089 return qe_invalid;
10090 }
10091
10092
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10093 {
10094 return qe_invalid;
10095 }
10096
10097
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10098 {
10099 return qe_invalid;
10100 }
10101
10102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10103 {
10104 304 swimspr[i][spr_tile]=(int32_t)tile;
10105 304 swimspr[i][spr_flip]=(int32_t)flip;
10106 304 swimspr[i][spr_extend]=(int32_t)extend;
10107 304 }
10108 304 }
10109 76 }
10110
10111
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10112 {
10113
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10114 {
10115 return qe_invalid;
10116 }
10117
10118
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10119 {
10120 return qe_invalid;
10121 }
10122
10123
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10124 {
10125 return qe_invalid;
10126 }
10127
10128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10129 {
10130 304 divespr[i][spr_tile]=(int32_t)tile;
10131 304 divespr[i][spr_flip]=(int32_t)flip;
10132 304 divespr[i][spr_extend]=(int32_t)extend;
10133 304 }
10134 304 }
10135
10136
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10137 {
10138
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10139 {
10140 return qe_invalid;
10141 }
10142
10143
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10144 {
10145 return qe_invalid;
10146 }
10147
10148
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10149 {
10150 return qe_invalid;
10151 }
10152
10153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10154 {
10155 304 poundspr[i][spr_tile]=(int32_t)tile;
10156 304 poundspr[i][spr_flip]=(int32_t)flip;
10157 304 poundspr[i][spr_extend]=(int32_t)extend;
10158 304 }
10159 304 }
10160
10161
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_igetw(&tile,f,keepdata))
10162 {
10163 return qe_invalid;
10164 }
10165
10166 76 flip=0;
10167
10168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>0)
10169 {
10170
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&flip,f,keepdata))
10171 {
10172 return qe_invalid;
10173 }
10174 76 }
10175
10176
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&extend,f,keepdata))
10177 {
10178 return qe_invalid;
10179 }
10180
10181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(keepdata)
10182 {
10183 76 castingspr[spr_tile]=(int32_t)tile;
10184 76 castingspr[spr_flip]=(int32_t)flip;
10185 76 castingspr[spr_extend]=(int32_t)extend;
10186 76 }
10187
10188
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(v_herosprites>0)
10189 {
10190 76 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10191
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 76 times.
228 for(int32_t i=0; i<2; i++)
10192 {
10193
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 152 times.
456 for(int32_t j=0; j<num_holdsprs; j++)
10194 {
10195
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10196 {
10197 return qe_invalid;
10198 }
10199
10200
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10201 {
10202 return qe_invalid;
10203 }
10204
10205
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10206 {
10207 return qe_invalid;
10208 }
10209
10210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10211 {
10212 304 holdspr[i][j][spr_tile]=(int32_t)tile;
10213 304 holdspr[i][j][spr_flip]=(int32_t)flip;
10214 304 holdspr[i][j][spr_extend]=(int32_t)extend;
10215 304 }
10216 304 }
10217 152 }
10218 76 }
10219 else
10220 {
10221 for(int32_t i=0; i<2; i++)
10222 {
10223 if(!p_igetw(&tile,f,keepdata))
10224 {
10225 return qe_invalid;
10226 }
10227
10228 if(!p_igetw(&tile2,f,keepdata))
10229 {
10230 return qe_invalid;
10231 }
10232
10233 if(!p_getc(&extend,f,keepdata))
10234 {
10235 return qe_invalid;
10236 }
10237
10238 if(keepdata)
10239 {
10240 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10241 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10242 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10243 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10244 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10245 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10246 }
10247 }
10248 }
10249
10250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>2)
10251 {
10252
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10253 {
10254
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10255 {
10256 return qe_invalid;
10257 }
10258
10259
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10260 {
10261 return qe_invalid;
10262 }
10263
10264
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10265 {
10266 return qe_invalid;
10267 }
10268
10269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10270 {
10271 304 jumpspr[i][spr_tile]=(int32_t)tile;
10272 304 jumpspr[i][spr_flip]=(int32_t)flip;
10273 304 jumpspr[i][spr_extend]=(int32_t)extend;
10274 304 }
10275 304 }
10276 76 }
10277
10278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>3)
10279 {
10280
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
10281 {
10282
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_igetw(&tile,f,keepdata))
10283 {
10284 return qe_invalid;
10285 }
10286
10287
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&flip,f,keepdata))
10288 {
10289 return qe_invalid;
10290 }
10291
10292
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(!p_getc(&extend,f,keepdata))
10293 {
10294 return qe_invalid;
10295 }
10296
10297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(keepdata)
10298 {
10299 304 chargespr[i][spr_tile]=(int32_t)tile;
10300 304 chargespr[i][spr_flip]=(int32_t)flip;
10301 304 chargespr[i][spr_extend]=(int32_t)extend;
10302 304 }
10303 304 }
10304 76 }
10305
10306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(v_herosprites>4)
10307 {
10308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(!p_getc(&dummy_byte,f,keepdata))
10309 {
10310 return qe_invalid;
10311 }
10312
10313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(keepdata)
10314 {
10315 76 zinit.hero_swim_speed=(byte)dummy_byte;
10316 76 }
10317 76 }
10318
10319
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(keepdata)
10320 {
10321 76 memset(frozenspr, 0, sizeof(frozenspr));
10322 76 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10323 76 memset(onfirespr, 0, sizeof(onfirespr));
10324 76 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10325 76 memset(diggingspr, 0, sizeof(diggingspr));
10326 76 memset(usingrodspr, 0, sizeof(usingrodspr));
10327 76 memset(usingcanespr, 0, sizeof(usingcanespr));
10328 76 memset(pushingspr, 0, sizeof(pushingspr));
10329 76 memset(liftingspr, 0, sizeof(liftingspr));
10330 76 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10331 76 memset(stunnedspr, 0, sizeof(stunnedspr));
10332 76 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10333 76 memset(fallingspr, 0, sizeof(fallingspr));
10334 76 memset(shockedspr, 0, sizeof(shockedspr));
10335 76 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10336 76 memset(pullswordspr, 0, sizeof(pullswordspr));
10337 76 memset(readingspr, 0, sizeof(readingspr));
10338 76 memset(slash180spr, 0, sizeof(slash180spr));
10339 76 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10340 76 memset(dashspr, 0, sizeof(dashspr));
10341 76 memset(bonkspr, 0, sizeof(bonkspr));
10342 76 memset(medallionsprs, 0, sizeof(medallionsprs));
10343 76 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10344 76 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10345
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t q = 0; q < 4; ++q)
10346 {
10347
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 304 times.
1216 for(int32_t p = 0; p < 3; ++p)
10348 {
10349 912 drowningspr[q][p] = divespr[q][p];
10350 912 drowning_lavaspr[q][p] = divespr[q][p];
10351 912 }
10352 304 }
10353 76 memset(sideswimspr, 0, sizeof(sideswimspr));
10354 76 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10355 76 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10356 76 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10357 76 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10358 76 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10359 76 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10360 76 }
10361 76 }
10362
10363
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
89 if(keepdata && FFCore.quest_format[vInitData] < 34)
10364 {
10365 89 bool fastswim = zinit.hero_swim_speed > 60;
10366 // '2/3' or '1/2'
10367 89 zinit.hero_swim_mult = fastswim ? 2 : 1;
10368 89 zinit.hero_swim_div = fastswim ? 3 : 2;
10369 89 }
10370 89 return 0;
10371 89 }
10372
10373 4930 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10374 {
10375 4930 arr[spr_tile] = tile;
10376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4930 times.
4930 arr[spr_flip] = (flip > 3 ? 0 : flip);
10377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4930 times.
4930 arr[spr_extend] = (ext > 2 ? 0 : ext);
10378 4930 }
10379 //Used to read the player sprites as int32_t, not word.
10380 29 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10381 {
10382 //these are here to bypass compiler warnings about unused arguments
10383 29 cv_herosprites=cv_herosprites;
10384
10385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(keepdata)
10386 {
10387 29 zinit.hero_swim_speed=67; //default
10388 29 setupherotiles(zinit.heroAnimationStyle);
10389 29 setupherodefenses();
10390 29 setupherooffsets();
10391 29 }
10392
10393 int32_t tile, tile2;
10394 byte flip, extend, dummy_byte;
10395
10396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(v_herosprites>=0)
10397 {
10398
10399
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10400 {
10401
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10402 {
10403 return qe_invalid;
10404 }
10405
10406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10407 {
10408 return qe_invalid;
10409 }
10410
10411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10412 {
10413 return qe_invalid;
10414 }
10415
10416 116 if(keepdata)
10417 {
10418 116 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10419 116 }
10420 116 }
10421
10422
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10423 {
10424
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10425 {
10426 return qe_invalid;
10427 }
10428
10429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10430 {
10431 return qe_invalid;
10432 }
10433
10434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10435 {
10436 return qe_invalid;
10437 }
10438
10439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10440 {
10441 116 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10442 116 }
10443 116 }
10444
10445
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10446 {
10447
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10448 {
10449 return qe_invalid;
10450 }
10451
10452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10453 {
10454 return qe_invalid;
10455 }
10456
10457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10458 {
10459 return qe_invalid;
10460 }
10461
10462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10463 {
10464 116 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10465 116 }
10466 116 }
10467
10468
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10469 {
10470
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10471 {
10472 return qe_invalid;
10473 }
10474
10475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10476 {
10477 return qe_invalid;
10478 }
10479
10480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10481 {
10482 return qe_invalid;
10483 }
10484
10485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10486 {
10487 116 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10488 116 }
10489 116 }
10490
10491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(v_herosprites>1)
10492 {
10493
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10494 {
10495
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10496 {
10497 return qe_invalid;
10498 }
10499
10500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10501 {
10502 return qe_invalid;
10503 }
10504
10505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10506 {
10507 return qe_invalid;
10508 }
10509
10510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10511 {
10512 116 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10513 116 }
10514 116 }
10515 29 }
10516
10517
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10518 {
10519
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10520 {
10521 return qe_invalid;
10522 }
10523
10524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10525 {
10526 return qe_invalid;
10527 }
10528
10529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10530 {
10531 return qe_invalid;
10532 }
10533
10534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10535 {
10536 116 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10537 116 }
10538 116 }
10539
10540
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10541 {
10542
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10543 {
10544 return qe_invalid;
10545 }
10546
10547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10548 {
10549 return qe_invalid;
10550 }
10551
10552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10553 {
10554 return qe_invalid;
10555 }
10556
10557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10558 {
10559 116 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10560 116 }
10561 116 }
10562
10563
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tile,f,keepdata))
10564 {
10565 return qe_invalid;
10566 }
10567
10568 29 flip=0;
10569
10570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(v_herosprites>0)
10571 {
10572
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&flip,f,keepdata))
10573 {
10574 return qe_invalid;
10575 }
10576 29 }
10577
10578
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&extend,f,keepdata))
10579 {
10580 return qe_invalid;
10581 }
10582
10583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(keepdata)
10584 {
10585 29 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10586 29 }
10587
10588
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(v_herosprites>0)
10589 {
10590 29 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10591
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 29 times.
87 for(int32_t i=0; i<2; i++)
10592 {
10593
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 58 times.
232 for(int32_t j=0; j<num_holdsprs; j++)
10594 {
10595
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 if(!p_igetl(&tile,f,keepdata))
10596 {
10597 return qe_invalid;
10598 }
10599
10600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if(!p_getc(&flip,f,keepdata))
10601 {
10602 return qe_invalid;
10603 }
10604
10605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if(!p_getc(&extend,f,keepdata))
10606 {
10607 return qe_invalid;
10608 }
10609
10610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if(keepdata)
10611 {
10612 174 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10613 174 }
10614 174 }
10615 58 }
10616 29 }
10617 else
10618 {
10619 for(int32_t i=0; i<2; i++)
10620 {
10621 if(!p_igetl(&tile,f,keepdata))
10622 {
10623 return qe_invalid;
10624 }
10625
10626 if(!p_igetl(&tile2,f,keepdata))
10627 {
10628 return qe_invalid;
10629 }
10630
10631 if(!p_getc(&extend,f,keepdata))
10632 {
10633 return qe_invalid;
10634 }
10635
10636 if(keepdata)
10637 {
10638 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10639 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10640 }
10641 }
10642 }
10643
10644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(v_herosprites>2)
10645 {
10646
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10647 {
10648
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10649 {
10650 return qe_invalid;
10651 }
10652
10653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10654 {
10655 return qe_invalid;
10656 }
10657
10658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10659 {
10660 return qe_invalid;
10661 }
10662
10663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10664 {
10665 116 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10666 116 }
10667 116 }
10668 29 }
10669
10670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(v_herosprites>3)
10671 {
10672
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t i=0; i<4; i++)
10673 {
10674
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10675 {
10676 return qe_invalid;
10677 }
10678
10679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10680 {
10681 return qe_invalid;
10682 }
10683
10684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10685 {
10686 return qe_invalid;
10687 }
10688
10689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10690 {
10691 116 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10692 116 }
10693 116 }
10694 29 }
10695
10696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(v_herosprites>4)
10697 {
10698
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&dummy_byte,f,keepdata))
10699 {
10700 return qe_invalid;
10701 }
10702
10703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(keepdata)
10704 {
10705 29 zinit.hero_swim_speed=(byte)dummy_byte;
10706 29 }
10707 29 }
10708
10709
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(v_herosprites>6)
10710 {
10711
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10712 {
10713
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10714 return qe_invalid;
10715
10716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10717 return qe_invalid;
10718
10719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10720 return qe_invalid;
10721
10722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10723 {
10724 116 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10725 116 }
10726 116 }
10727
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10728 {
10729
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10730 return qe_invalid;
10731
10732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10733 return qe_invalid;
10734
10735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10736 return qe_invalid;
10737
10738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10739 {
10740 116 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10741 116 }
10742 116 }
10743
10744
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10745 {
10746
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10747 return qe_invalid;
10748
10749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10750 return qe_invalid;
10751
10752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10753 return qe_invalid;
10754
10755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10756 {
10757 116 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10758 116 }
10759 116 }
10760
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10761 {
10762
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10763 return qe_invalid;
10764
10765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10766 return qe_invalid;
10767
10768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10769 return qe_invalid;
10770
10771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10772 {
10773 116 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10774 116 }
10775 116 }
10776
10777
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10778 {
10779
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10780 return qe_invalid;
10781
10782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10783 return qe_invalid;
10784
10785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10786 return qe_invalid;
10787
10788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10789 {
10790 116 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10791 116 }
10792 116 }
10793
10794
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10795 {
10796
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10797 return qe_invalid;
10798
10799
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10800 return qe_invalid;
10801
10802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10803 return qe_invalid;
10804
10805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10806 {
10807 116 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10808 116 }
10809 116 }
10810
10811
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10812 {
10813
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10814 return qe_invalid;
10815
10816
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10817 return qe_invalid;
10818
10819
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10820 return qe_invalid;
10821
10822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10823 {
10824 116 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10825 116 }
10826 116 }
10827
10828
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10829 {
10830
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10831 return qe_invalid;
10832
10833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
10834 return qe_invalid;
10835
10836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10837 return qe_invalid;
10838
10839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10840 {
10841 116 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10842 116 }
10843 116 }
10844
10845
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10846 {
10847
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10848 return qe_invalid;
10849
10850
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10851 return qe_invalid;
10852
10853
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10854 return qe_invalid;
10855
10856 116 byte frames = 0;
10857
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 108 times.
116 if(v_herosprites > 15)
10858 {
10859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!p_getc(&frames,f,keepdata))
10860 return qe_invalid;
10861 108 }
10862
10863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10864 {
10865 116 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10866 116 liftingspr[q][spr_frames] = frames;
10867 116 }
10868 116 }
10869
10870
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10871 {
10872
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10873 return qe_invalid;
10874
10875
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10876 return qe_invalid;
10877
10878
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10879 return qe_invalid;
10880
10881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10882 {
10883 116 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10884 116 }
10885 116 }
10886
10887
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10888 {
10889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_igetl(&tile,f,keepdata))
10890 return qe_invalid;
10891
10892
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10893 return qe_invalid;
10894
10895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10896 return qe_invalid;
10897
10898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10899 {
10900 116 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10901 116 }
10902 116 }
10903
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10904 {
10905
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10906 return qe_invalid;
10907
10908
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10909 return qe_invalid;
10910
10911
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10912 return qe_invalid;
10913
10914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10915 {
10916 116 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10917 116 }
10918 116 }
10919
10920
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10921 {
10922
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10923 return qe_invalid;
10924
10925
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10926 return qe_invalid;
10927
10928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
10929 return qe_invalid;
10930
10931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10932 {
10933 116 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10934 116 }
10935 116 }
10936
10937
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10938 {
10939
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10940 return qe_invalid;
10941
10942
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10943 return qe_invalid;
10944
10945
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10946 return qe_invalid;
10947
10948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10949 {
10950 116 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10951 116 }
10952 116 }
10953
10954
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10955 {
10956
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10957 return qe_invalid;
10958
10959
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10960 return qe_invalid;
10961
10962
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10963 return qe_invalid;
10964
10965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10966 {
10967 116 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10968 116 }
10969 116 }
10970
10971
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10972 {
10973
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10974 return qe_invalid;
10975
10976
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10977 return qe_invalid;
10978
10979
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10980 return qe_invalid;
10981
10982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10983 {
10984 116 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10985 116 }
10986 116 }
10987
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
10988 {
10989
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
10990 return qe_invalid;
10991
10992
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
10993 return qe_invalid;
10994
10995
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
10996 return qe_invalid;
10997
10998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
10999 {
11000 116 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11001 116 }
11002 116 }
11003
11004
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11005 {
11006
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11007 return qe_invalid;
11008
11009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11010 return qe_invalid;
11011
11012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11013 return qe_invalid;
11014
11015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11016 {
11017 116 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11018 116 }
11019 116 }
11020
11021
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11022 {
11023
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11024 return qe_invalid;
11025
11026
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
11027 return qe_invalid;
11028
11029
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
11030 return qe_invalid;
11031
11032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11033 {
11034 116 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11035 116 }
11036 116 }
11037
11038
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11039 {
11040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_igetl(&tile,f,keepdata))
11041 return qe_invalid;
11042
11043
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
11044 return qe_invalid;
11045
11046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11047 return qe_invalid;
11048
11049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11050 {
11051 116 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11052 116 }
11053 116 }
11054
11055
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11056 {
11057
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11058 return qe_invalid;
11059
11060
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
11061 return qe_invalid;
11062
11063
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
11064 return qe_invalid;
11065
11066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11067 {
11068 116 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11069 116 }
11070 116 }
11071
11072
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11073 {
11074
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11075 return qe_invalid;
11076
11077
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
11078 return qe_invalid;
11079
11080
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
11081 return qe_invalid;
11082
11083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11084 {
11085 116 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11086 116 }
11087 116 }
11088
11089
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11090 {
11091
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11092 return qe_invalid;
11093
11094
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&flip,f,keepdata))
11095 return qe_invalid;
11096
11097
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_getc(&extend,f,keepdata))
11098 return qe_invalid;
11099
11100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11101 {
11102 116 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11103 116 }
11104 116 }
11105
11106
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 29 times.
116 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
11107 {
11108
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if(!p_igetl(&tile,f,keepdata))
11109 return qe_invalid;
11110
11111
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if(!p_getc(&flip,f,keepdata))
11112 return qe_invalid;
11113
11114
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if(!p_getc(&extend,f,keepdata))
11115 return qe_invalid;
11116
11117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(keepdata)
11118 {
11119 87 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11120 87 }
11121 87 }
11122 29 }
11123 else if(keepdata)
11124 {
11125 memset(frozenspr, 0, sizeof(frozenspr));
11126 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11127 memset(onfirespr, 0, sizeof(onfirespr));
11128 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11129 memset(diggingspr, 0, sizeof(diggingspr));
11130 memset(usingrodspr, 0, sizeof(usingrodspr));
11131 memset(usingcanespr, 0, sizeof(usingcanespr));
11132 memset(pushingspr, 0, sizeof(pushingspr));
11133 memset(liftingspr, 0, sizeof(liftingspr));
11134 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11135 memset(stunnedspr, 0, sizeof(stunnedspr));
11136 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11137 memset(fallingspr, 0, sizeof(fallingspr));
11138 memset(shockedspr, 0, sizeof(shockedspr));
11139 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11140 memset(pullswordspr, 0, sizeof(pullswordspr));
11141 memset(readingspr, 0, sizeof(readingspr));
11142 memset(slash180spr, 0, sizeof(slash180spr));
11143 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11144 memset(dashspr, 0, sizeof(dashspr));
11145 memset(bonkspr, 0, sizeof(bonkspr));
11146 memset(medallionsprs, 0, sizeof(medallionsprs));
11147 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11148 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11149 for(int32_t q = 0; q < 4; ++q)
11150 {
11151 for(int32_t p = 0; p < 3; ++p)
11152 {
11153 drowningspr[q][p] = divespr[q][p];
11154 drowning_lavaspr[q][p] = divespr[q][p];
11155 }
11156 }
11157 }
11158
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 8)
11159 {
11160
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11161 {
11162
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11163 return qe_invalid;
11164
11165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11166 return qe_invalid;
11167
11168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11169 return qe_invalid;
11170
11171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11172 {
11173 116 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11174 116 }
11175 116 }
11176 29 }
11177 else if (keepdata)
11178 {
11179 memset(sideswimspr, 0, sizeof(sideswimspr));
11180 }
11181
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 9)
11182 {
11183
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11184 {
11185
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11186 return qe_invalid;
11187
11188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11189 return qe_invalid;
11190
11191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11192 return qe_invalid;
11193
11194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11195 {
11196 116 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11197 116 }
11198 116 }
11199
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11200 {
11201
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11202 return qe_invalid;
11203
11204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11205 return qe_invalid;
11206
11207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11208 return qe_invalid;
11209
11210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11211 {
11212 116 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11213 116 }
11214 116 }
11215
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11216 {
11217
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11218 return qe_invalid;
11219
11220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11221 return qe_invalid;
11222
11223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11224 return qe_invalid;
11225
11226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11227 {
11228 116 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11229 116 }
11230 116 }
11231
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11232 {
11233
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11234 return qe_invalid;
11235
11236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11237 return qe_invalid;
11238
11239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11240 return qe_invalid;
11241
11242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11243 {
11244 116 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11245 116 }
11246 116 }
11247 29 }
11248 else if (keepdata)
11249 {
11250 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11251 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11252 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11253 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11254 }
11255
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 10)
11256 {
11257
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11258 {
11259 int32_t hmr;
11260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_igetl(&hmr,f,keepdata))
11261 return qe_invalid;
11262
11263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11264 {
11265 116 hammeroffsets[q] = hmr;
11266 116 }
11267 116 }
11268 29 }
11269 else if (keepdata)
11270 {
11271 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11272 }
11273
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 11)
11274 {
11275
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 29 times.
116 for(int32_t q = 0; q < 3; ++q)
11276 {
11277
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if(!p_igetl(&tile,f,keepdata))
11278 return qe_invalid;
11279
11280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(!p_getc(&flip,f,keepdata))
11281 return qe_invalid;
11282
11283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(!p_getc(&extend,f,keepdata))
11284 return qe_invalid;
11285
11286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(keepdata)
11287 {
11288 87 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11289 87 }
11290 87 }
11291 29 }
11292 else if (keepdata)
11293 {
11294 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11295 }
11296
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 12)
11297 {
11298
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tile,f,keepdata))
11299 return qe_invalid;
11300
11301
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&flip,f,keepdata))
11302 return qe_invalid;
11303
11304
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&extend,f,keepdata))
11305 return qe_invalid;
11306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if (keepdata)
11307 {
11308 29 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11309 29 }
11310
11311 29 }
11312 else if (keepdata)
11313 {
11314 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11315 }
11316
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 13)
11317 {
11318
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11319 {
11320
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11321 return qe_invalid;
11322
11323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11324 return qe_invalid;
11325
11326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11327 return qe_invalid;
11328
11329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11330 {
11331 116 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11332 116 }
11333 116 }
11334 29 }
11335 else if (keepdata)
11336 {
11337 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11338 }
11339
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 14)
11340 {
11341
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
11342 {
11343
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!p_igetl(&tile,f,keepdata))
11344 return qe_invalid;
11345
11346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&flip,f,keepdata))
11347 return qe_invalid;
11348
11349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_getc(&extend,f,keepdata))
11350 return qe_invalid;
11351
11352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(keepdata)
11353 {
11354 116 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11355 116 }
11356 116 }
11357 29 }
11358 else if (keepdata)
11359 {
11360 memset(revslashspr, 0, sizeof(revslashspr));
11361 }
11362
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (v_herosprites > 7)
11363 {
11364 29 int32_t num_defense = wMax;
11365 29 byte def = 0;
11366
11367 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11368 /*if(v_herosprites > [x])
11369 * {
11370 * num_defense = 146 //value of wMax on version 8
11371 * }
11372 */
11373
11374
2/2
✓ Branch 0 taken 4234 times.
✓ Branch 1 taken 29 times.
4263 for (int32_t q = 0; q < num_defense; q++)
11375 {
11376
1/2
✓ Branch 0 taken 4234 times.
✗ Branch 1 not taken.
4234 if (!p_getc(&def, f, keepdata))
11377 return qe_invalid;
11378
11379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4234 times.
4234 if (keepdata)
11380 {
11381 4234 hero_defence[q] = def;
11382 4234 }
11383 4234 }
11384 29 }
11385 else if (keepdata)
11386 {
11387 int32_t num_defense = wMax;
11388 for (int32_t q = 0; q < num_defense; q++)
11389 {
11390 hero_defence[q] = 0;
11391 }
11392 }
11393 29 }
11394
11395
3/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 5 times.
29 if(keepdata && FFCore.quest_format[vInitData] < 34)
11396 {
11397 5 bool fastswim = zinit.hero_swim_speed > 60;
11398 // '2/3' or '1/2'
11399 5 zinit.hero_swim_mult = fastswim ? 2 : 1;
11400 5 zinit.hero_swim_div = fastswim ? 3 : 2;
11401 5 }
11402 29 return 0;
11403 29 }
11404
11405
11406 105 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11407 {
11408 //these are here to bypass compiler warnings about unused arguments
11409 105 Header=Header;
11410
11411 dword dummy;
11412 105 word s_version=0, s_cversion=0;
11413
11414 //section version info
11415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
11416 {
11417 return qe_invalid;
11418 }
11419
11420 105 FFCore.quest_format[vHeroSprites] = s_version;
11421
11422 //al_trace("Player sprites version %d\n", s_version);
11423
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
11424 {
11425 return qe_invalid;
11426 }
11427
11428 //section size
11429
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
11430 {
11431 return qe_invalid;
11432 }
11433
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if ( s_version >= 6 )
11434 {
11435 //al_trace("Reading Player Sprites v6\n");
11436 29 return readherosprites3(f, s_version, dummy, keepdata);
11437 }
11438 76 else return readherosprites2(f, s_version, dummy, keepdata);
11439 105 }
11440
11441 105 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11442 {
11443 int32_t dummy;
11444 105 word s_version=0, s_cversion=0;
11445
11446 //section version info
11447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
11448 {
11449 return qe_invalid;
11450 }
11451
11452 105 FFCore.quest_format[vSubscreen] = s_version;
11453
11454 //al_trace("Subscreens version %d\n", s_version);
11455
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
11456 {
11457 return qe_invalid;
11458 }
11459
11460 //section size
11461
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
11462 {
11463 return qe_invalid;
11464 }
11465
11466 //finally... section data
11467
2/2
✓ Branch 0 taken 13440 times.
✓ Branch 1 taken 105 times.
13545 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11468 {
11469 13440 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11470
11471
1/2
✓ Branch 0 taken 13440 times.
✗ Branch 1 not taken.
13440 if(ret!=0) return ret;
11472 13440 }
11473
11474 105 return 0;
11475 105 }
11476
11477 13440 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11478 {
11479 13440 int32_t numsub=0;
11480 13440 byte temp_ss=0;
11481 subscreen_object temp_sub_stack;
11482 13440 subscreen_object *temp_sub = &temp_sub_stack;
11483
11484 char tempname[64];
11485
11486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13440 times.
13440 if(!pfread(tempname,64,f,true))
11487 {
11488 return qe_invalid;
11489 }
11490
11491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13440 times.
13440 if(s_version > 1)
11492 {
11493
1/2
✓ Branch 0 taken 13440 times.
✗ Branch 1 not taken.
13440 if(!p_getc(&temp_ss,f,keepdata))
11494 {
11495 return qe_invalid;
11496 }
11497 13440 }
11498
11499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13440 times.
13440 if(s_version < 4)
11500 {
11501 uint8_t tmp=0;
11502
11503 if(!p_getc(&tmp,f,true))
11504 {
11505 return qe_invalid;
11506 }
11507
11508 numsub = (int32_t)tmp;
11509 }
11510 else
11511 {
11512 word tmp;
11513
11514
1/2
✓ Branch 0 taken 13440 times.
✗ Branch 1 not taken.
13440 if(!p_igetw(&tmp, f, true))
11515 {
11516 return qe_invalid;
11517 }
11518
11519 13440 numsub = (int32_t)tmp;
11520 }
11521
11522 int32_t j;
11523
11524
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37459 times.
✓ Branch 2 taken 24019 times.
✓ Branch 3 taken 13440 times.
37459 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11525 {
11526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24019 times.
24019 if(keepdata)
11527 {
11528 24019 memset(temp_sub,0,sizeof(subscreen_object));
11529
11530
2/2
✓ Branch 0 taken 1199 times.
✓ Branch 1 taken 22820 times.
24019 switch(custom_subscreen[i].objects[j].type)
11531 {
11532 case ssoTEXT:
11533 case ssoTEXTBOX:
11534 case ssoCURRENTITEMTEXT:
11535 case ssoCURRENTITEMCLASSTEXT:
11536
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1199 times.
✓ Branch 2 taken 1199 times.
✗ Branch 3 not taken.
1199 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11537
11538 //fall through
11539 default:
11540 24019 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11541 24019 break;
11542 }
11543 24019 }
11544
11545
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->type),f,true))
11546 {
11547 return qe_invalid;
11548 }
11549
11550
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->pos),f,keepdata))
11551 {
11552 return qe_invalid;
11553 }
11554
11555
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(s_version < 5)
11556 {
11557 switch(temp_sub->pos)
11558 {
11559 case 0:
11560 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11561 break;
11562
11563 case 1:
11564 temp_sub->pos = sspUP;
11565 break;
11566
11567 case 2:
11568 temp_sub->pos = sspDOWN;
11569 break;
11570
11571 default:
11572 temp_sub->pos = 0;
11573 }
11574 }
11575
11576
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->x),f,keepdata))
11577 {
11578 return qe_invalid;
11579 }
11580
11581
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->y),f,keepdata))
11582 {
11583 return qe_invalid;
11584 }
11585
11586
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->w),f,keepdata))
11587 {
11588 return qe_invalid;
11589 }
11590
11591
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->h),f,keepdata))
11592 {
11593 return qe_invalid;
11594 }
11595
11596
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11597 {
11598 return qe_invalid;
11599 }
11600
11601
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11602 {
11603 return qe_invalid;
11604 }
11605
11606
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11607 {
11608 return qe_invalid;
11609 }
11610
11611
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11612 {
11613 return qe_invalid;
11614 }
11615
11616
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11617 {
11618 return qe_invalid;
11619 }
11620
11621
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11622 {
11623 return qe_invalid;
11624 }
11625
11626
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11627 {
11628 return qe_invalid;
11629 }
11630
11631
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11632 {
11633 return qe_invalid;
11634 }
11635
11636
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11637 {
11638 return qe_invalid;
11639 }
11640
11641
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11642 {
11643 return qe_invalid;
11644 }
11645
11646
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11647 {
11648 return qe_invalid;
11649 }
11650
11651
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11652 {
11653 return qe_invalid;
11654 }
11655
11656
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11657 {
11658 return qe_invalid;
11659 }
11660
11661
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11662 {
11663 return qe_invalid;
11664 }
11665
11666
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11667 {
11668 return qe_invalid;
11669 }
11670
11671
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11672 {
11673 return qe_invalid;
11674 }
11675
11676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24019 times.
24019 if(s_version < 2)
11677 {
11678 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11679 {
11680 return qe_invalid;
11681 }
11682
11683 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11684 {
11685 return qe_invalid;
11686 }
11687
11688 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11689 {
11690 return qe_invalid;
11691 }
11692 }
11693 else
11694 {
11695
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->speed),f,keepdata))
11696 {
11697 return qe_invalid;
11698 }
11699
11700
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_getc(&(temp_sub->delay),f,keepdata))
11701 {
11702 return qe_invalid;
11703 }
11704
11705
1/2
✓ Branch 0 taken 24019 times.
✗ Branch 1 not taken.
24019 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11706 {
11707 return qe_invalid;
11708 }
11709 }
11710
11711 24019 int32_t temp_size=0;
11712
11713 // bool deletets = false;
11714
4/4
✓ Branch 0 taken 10119 times.
✓ Branch 1 taken 1794 times.
✓ Branch 2 taken 11957 times.
✓ Branch 3 taken 149 times.
24019 switch(temp_sub->type)
11715 {
11716 case ssoTEXT:
11717 case ssoTEXTBOX:
11718 case ssoCURRENTITEMTEXT:
11719 case ssoCURRENTITEMCLASSTEXT:
11720 word temptempsize;
11721 /*uint8_t temp1;
11722 uint8_t temp2;
11723 temp2 = 0;
11724 if(!p_getc(&temp1,f,true))
11725 {
11726 return qe_invalid;
11727 }
11728 if(temp1)
11729 {
11730
11731 if(!p_getc(&temp2,f,true))
11732 {
11733 return qe_invalid;
11734 }
11735 }*/
11736
11737
1/2
✓ Branch 0 taken 1794 times.
✗ Branch 1 not taken.
1794 if(!p_igetw(&temptempsize,f,true))
11738 {
11739 return qe_invalid;
11740 }
11741
11742 //temptempsize = temp1 + (temp2 << 8);
11743 1794 temp_size = (int32_t)temptempsize;
11744
11745 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
1794 if(keepdata)
11747 {
11748 1794 uint32_t char_length = temp_size+1;
11749 1794 temp_sub->dp1 = new char[char_length]; //memory not freed
11750
11751 //deletets = true; //obsolete
11752 1794 }
11753
11754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
1794 if(temp_size)
11755 {
11756
1/2
✓ Branch 0 taken 1794 times.
✗ Branch 1 not taken.
1794 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11757 {
11758 return qe_invalid;
11759 }
11760 1794 }
11761
11762 1794 break;
11763
11764 case ssoLIFEMETER:
11765
1/2
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
149 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11766 temp_sub->d3 = 1;
11767
11768
1/2
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
149 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11769 {
11770 return qe_invalid;
11771 }
11772
11773 149 break;
11774
11775
11776 case ssoCURRENTITEM:
11777
11778
1/2
✓ Branch 0 taken 10119 times.
✗ Branch 1 not taken.
10119 if(s_version < 6)
11779 {
11780 switch(temp_sub->d1)
11781 {
11782 case ssiBOMB:
11783 temp_sub->d1 = itype_bomb;
11784 break;
11785
11786 case ssiSWORD:
11787 temp_sub->d1 = itype_sword;
11788 break;
11789
11790 case ssiSHIELD:
11791 temp_sub->d1 = itype_shield;
11792 break;
11793
11794 case ssiCANDLE:
11795 temp_sub->d1 = itype_candle;
11796 break;
11797
11798 case ssiLETTER:
11799 temp_sub->d1 = itype_letter;
11800 break;
11801
11802 case ssiPOTION:
11803 temp_sub->d1 = itype_potion;
11804 break;
11805
11806 case ssiLETTERPOTION:
11807 temp_sub->d1 = itype_letterpotion;
11808 break;
11809
11810 case ssiBOW:
11811 temp_sub->d1 = itype_bow;
11812 break;
11813
11814 case ssiARROW:
11815 temp_sub->d1 = itype_arrow;
11816 break;
11817
11818 case ssiBOWANDARROW:
11819 temp_sub->d1 = itype_bowandarrow;
11820 break;
11821
11822 case ssiBAIT:
11823 temp_sub->d1 = itype_bait;
11824 break;
11825
11826 case ssiRING:
11827 temp_sub->d1 = itype_ring;
11828 break;
11829
11830 case ssiBRACELET:
11831 temp_sub->d1 = itype_bracelet;
11832 break;
11833
11834 case ssiMAP:
11835 temp_sub->d1 = itype_map;
11836 break;
11837
11838 case ssiCOMPASS:
11839 temp_sub->d1 = itype_compass;
11840 break;
11841
11842 case ssiBOSSKEY:
11843 temp_sub->d1 = itype_bosskey;
11844 break;
11845
11846 case ssiMAGICKEY:
11847 temp_sub->d1 = itype_magickey;
11848 break;
11849
11850 case ssiBRANG:
11851 temp_sub->d1 = itype_brang;
11852 break;
11853
11854 case ssiWAND:
11855 temp_sub->d1 = itype_wand;
11856 break;
11857
11858 case ssiRAFT:
11859 temp_sub->d1 = itype_raft;
11860 break;
11861
11862 case ssiLADDER:
11863 temp_sub->d1 = itype_ladder;
11864 break;
11865
11866 case ssiWHISTLE:
11867 temp_sub->d1 = itype_whistle;
11868 break;
11869
11870 case ssiBOOK:
11871 temp_sub->d1 = itype_book;
11872 break;
11873
11874 case ssiWALLET:
11875 temp_sub->d1 = itype_wallet;
11876 break;
11877
11878 case ssiSBOMB:
11879 temp_sub->d1 = itype_sbomb;
11880 break;
11881
11882 case ssiHCPIECE:
11883 temp_sub->d1 = itype_heartpiece;
11884 break;
11885
11886 case ssiAMULET:
11887 temp_sub->d1 = itype_amulet;
11888 break;
11889
11890 case ssiFLIPPERS:
11891 temp_sub->d1 = itype_flippers;
11892 break;
11893
11894 case ssiHOOKSHOT:
11895 temp_sub->d1 = itype_hookshot;
11896 break;
11897
11898 case ssiLENS:
11899 temp_sub->d1 = itype_lens;
11900 break;
11901
11902 case ssiHAMMER:
11903 temp_sub->d1 = itype_hammer;
11904 break;
11905
11906 case ssiBOOTS:
11907 temp_sub->d1 = itype_boots;
11908 break;
11909
11910 case ssiDIVINEFIRE:
11911 temp_sub->d1 = itype_divinefire;
11912 break;
11913
11914 case ssiDIVINEESCAPE:
11915 temp_sub->d1 = itype_divineescape;
11916 break;
11917
11918 case ssiDIVINEPROTECTION:
11919 temp_sub->d1 = itype_divineprotection;
11920 break;
11921
11922 case ssiQUIVER:
11923 temp_sub->d1 = itype_quiver;
11924 break;
11925
11926 case ssiBOMBBAG:
11927 temp_sub->d1 = itype_bombbag;
11928 break;
11929
11930 case ssiCBYRNA:
11931 temp_sub->d1 = itype_cbyrna;
11932 break;
11933
11934 case ssiROCS:
11935 temp_sub->d1 = itype_rocs;
11936 break;
11937
11938 case ssiHOVERBOOTS:
11939 temp_sub->d1 = itype_hoverboots;
11940 break;
11941
11942 case ssiSPINSCROLL:
11943 temp_sub->d1 = itype_spinscroll;
11944 break;
11945
11946 case ssiCROSSSCROLL:
11947 temp_sub->d1 = itype_crossscroll;
11948 break;
11949
11950 case ssiQUAKESCROLL:
11951 temp_sub->d1 = itype_quakescroll;
11952 break;
11953
11954 case ssiWHISPRING:
11955 temp_sub->d1 = itype_whispring;
11956 break;
11957
11958 case ssiCHARGERING:
11959 temp_sub->d1 = itype_chargering;
11960 break;
11961
11962 case ssiPERILSCROLL:
11963 temp_sub->d1 = itype_perilscroll;
11964 break;
11965
11966 case ssiWEALTHMEDAL:
11967 temp_sub->d1 = itype_wealthmedal;
11968 break;
11969
11970 case ssiHEARTRING:
11971 temp_sub->d1 = itype_heartring;
11972 break;
11973
11974 case ssiMAGICRING:
11975 temp_sub->d1 = itype_magicring;
11976 break;
11977
11978 case ssiSPINSCROLL2:
11979 temp_sub->d1 = itype_spinscroll2;
11980 break;
11981
11982 case ssiQUAKESCROLL2:
11983 temp_sub->d1 = itype_quakescroll2;
11984 break;
11985
11986 case ssiAGONY:
11987 temp_sub->d1 = itype_agony;
11988 break;
11989
11990 case ssiSTOMPBOOTS:
11991 temp_sub->d1 = itype_stompboots;
11992 break;
11993
11994 case ssiWHIMSICALRING:
11995 temp_sub->d1 = itype_whimsicalring;
11996 break;
11997
11998 case ssiPERILRING:
11999 temp_sub->d1 = itype_perilring;
12000 break;
12001
12002 default:
12003 temp_sub->d1 += itype_custom1 - ssiMAX;
12004 }
12005 }
12006
12007 //fall-through
12008 default:
12009
1/2
✓ Branch 0 taken 22076 times.
✗ Branch 1 not taken.
22076 if(!p_getc(&(temp_sub->dp1),f,keepdata))
12010 {
12011 return qe_invalid;
12012 }
12013
12014 22076 break;
12015 }
12016
12017
2/2
✓ Branch 0 taken 15419 times.
✓ Branch 1 taken 8600 times.
24019 if(s_version < 7)
12018 {
12019
3/3
✓ Branch 0 taken 7941 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8600 switch(temp_sub->type)
12020 {
12021 case ssoMAGICGAUGE:
12022 {
12023
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
12024 192 temp_sub->d9 = -1; //-1 now represents 'always'
12025 227 break;
12026 }
12027 case ssoLIFEGAUGE:
12028 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
12029 432 break;
12030 }
12031 8600 }
12032
12033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24019 times.
24019 if(keepdata)
12034 {
12035
3/3
✓ Branch 0 taken 1794 times.
✓ Branch 1 taken 21168 times.
✓ Branch 2 taken 1057 times.
24019 switch(temp_sub->type)
12036 {
12037 case ssoTEXT:
12038 case ssoTEXTBOX:
12039 case ssoCURRENTITEMTEXT:
12040 case ssoCURRENTITEMCLASSTEXT:
12041
1/4
✓ Branch 0 taken 1794 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1794 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
12042
12043 1794 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
12044 1794 custom_subscreen[i].objects[j].dp1 = NULL;
12045 1794 custom_subscreen[i].objects[j].dp1 = new char[temp_size+1];
12046 1794 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
12047 1794 break;
12048
12049 case ssoCOUNTER:
12050
1/2
✓ Branch 0 taken 1057 times.
✗ Branch 1 not taken.
1057 if(s_version<3)
12051 {
12052 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
12053 temp_sub->d8=0;
12054 }
12055
12056 default:
12057 22225 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
12058 22225 break;
12059 }
12060
12061 24019 strcpy(custom_subscreen[i].name, tempname);
12062 24019 custom_subscreen[i].ss_type = temp_ss;
12063 24019 }
12064 24019 }
12065
12066
2/2
✓ Branch 0 taken 3416621 times.
✓ Branch 1 taken 13440 times.
3430061 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
12067 {
12068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3416621 times.
3416621 if(keepdata)
12069 {
12070 //clear all unused object in this subscreen -DD
12071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3416621 times.
3416621 switch(custom_subscreen[i].objects[j].type)
12072 {
12073 case ssoTEXT:
12074 case ssoTEXTBOX:
12075 case ssoCURRENTITEMTEXT:
12076 case ssoCURRENTITEMCLASSTEXT:
12077 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
12078
12079 //fall through
12080 default:
12081 3416621 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
12082 3416621 break;
12083 }
12084 3416621 }
12085 3416621 }
12086
12087 13440 return 0;
12088 13440 }
12089
12090 2944 void reset_subscreen(subscreen_group *tempss)
12091 {
12092
2/2
✓ Branch 0 taken 753664 times.
✓ Branch 1 taken 2944 times.
756608 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
12093 {
12094
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 753522 times.
753664 switch(tempss->objects[i].type)
12095 {
12096 case ssoTEXT:
12097 case ssoTEXTBOX:
12098 case ssoCURRENTITEMTEXT:
12099 case ssoCURRENTITEMCLASSTEXT:
12100
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 142 times.
✗ Branch 3 not taken.
142 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
12101
12102 //fall through
12103 default:
12104 753664 memset(&tempss->objects[i],0,sizeof(subscreen_object));
12105 753664 break;
12106 }
12107 753664 }
12108 2944 }
12109
12110 23 void reset_subscreens()
12111 {
12112
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 23 times.
2967 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
12113 {
12114 2944 reset_subscreen(&custom_subscreen[i]);
12115 2944 }
12116 23 }
12117
12118 23 int32_t setupsubscreens()
12119 {
12120 23 reset_subscreens();
12121 23 int32_t tempsubscreen=zinit.subscreen;
12122 subscreen_object *tempsub;
12123
12124
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(tempsubscreen>=ssdtMAX)
12125 {
12126 tempsubscreen=0;
12127 }
12128
12129
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 switch(tempsubscreen)
12130 {
12131 case ssdtOLD:
12132 case ssdtNEWSUBSCR:
12133 case ssdtREV2:
12134 case ssdtBSZELDA:
12135 case ssdtBSZELDAMODIFIED:
12136 case ssdtBSZELDAENHANCED:
12137 case ssdtBSZELDACOMPLETE:
12138 {
12139 23 tempsub = default_subscreen_active[tempsubscreen][0];
12140 int32_t i;
12141
12142
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1518 times.
✓ Branch 2 taken 1495 times.
✓ Branch 3 taken 23 times.
1518 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12143 {
12144
2/3
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1431 times.
✗ Branch 2 not taken.
1495 switch(tempsub[i].type)
12145 {
12146 case ssoTEXT:
12147 case ssoTEXTBOX:
12148 case ssoCURRENTITEMTEXT:
12149 case ssoCURRENTITEMCLASSTEXT:
12150
1/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12151
12152 64 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12153 64 custom_subscreen[0].objects[i].dp1 = NULL;
12154 64 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12155 64 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12156 64 break;
12157
12158 case ssoLIFEMETER:
12159 {
12160 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12161
12162 if(get_bit(deprecated_rules, 12) != 0)
12163 custom_subscreen[0].objects[i].d3=1;
12164 else
12165 custom_subscreen[0].objects[i].d3=0;
12166
12167 break;
12168 }
12169 /*
12170 case ssoTRIFRAME:
12171 {
12172 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12173 custom_subscreen[0].objects[i].d1 = 8594;
12174 custom_subscreen[0].objects[i].d2 = 8;
12175 custom_subscreen[0].objects[i].d3 = 8771;
12176 custom_subscreen[0].objects[i].d4 = 8;
12177 custom_subscreen[0].objects[i].d5 = 1;
12178 custom_subscreen[0].objects[i].d6 = 1;
12179 break;
12180 }*/
12181
12182 default:
12183 1431 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12184 1431 break;
12185 }
12186 1495 }
12187
12188 23 custom_subscreen[0].ss_type=sstACTIVE;
12189 23 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12190 23 tempsub = default_subscreen_active[tempsubscreen][1];
12191
12192
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1518 times.
✓ Branch 2 taken 1495 times.
✓ Branch 3 taken 23 times.
1518 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12193 {
12194
2/3
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 1412 times.
✗ Branch 2 not taken.
1495 switch(tempsub[i].type)
12195 {
12196 case ssoTEXT:
12197 case ssoTEXTBOX:
12198 case ssoCURRENTITEMTEXT:
12199 case ssoCURRENTITEMCLASSTEXT:
12200
1/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
83 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12201
12202 83 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12203 83 custom_subscreen[1].objects[i].dp1 = NULL;
12204 83 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12205 83 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12206 83 break;
12207
12208 case ssoLIFEMETER:
12209 {
12210 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12211
12212 if(get_bit(deprecated_rules, 12) != 0)
12213 custom_subscreen[1].objects[i].d3=1;
12214 else
12215 custom_subscreen[1].objects[i].d3=0;
12216
12217 break;
12218 }
12219 /*
12220 case ssoTRIFRAME:
12221 {
12222 custom_subscreen[1].objects[i].d1 = 8594;
12223 custom_subscreen[1].objects[i].d2 = 8;
12224 custom_subscreen[1].objects[i].d3 = 8771;
12225 custom_subscreen[1].objects[i].d4 = 8;
12226 custom_subscreen[1].objects[i].d5 = 1;
12227 custom_subscreen[1].objects[i].d6 = 1;
12228 break;
12229 }*/
12230
12231 default:
12232 1412 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12233 1412 break;
12234 }
12235 1495 }
12236
12237 23 custom_subscreen[1].ss_type=sstACTIVE;
12238 23 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12239 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12240 23 tempsub = default_subscreen_passive[tempsubscreen][0];
12241
12242
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 483 times.
✓ Branch 2 taken 460 times.
✓ Branch 3 taken 23 times.
483 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12243 {
12244
3/3
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 368 times.
✓ Branch 2 taken 23 times.
460 switch(tempsub[i].type)
12245 {
12246 case ssoTEXT:
12247 case ssoTEXTBOX:
12248 case ssoCURRENTITEMTEXT:
12249 case ssoCURRENTITEMCLASSTEXT:
12250
1/4
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
69 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12251
12252 69 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12253 69 custom_subscreen[2].objects[i].dp1 = NULL;
12254 69 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12255 69 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12256 69 break;
12257
12258 case ssoLIFEMETER:
12259 {
12260 23 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12261
12262
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(get_bit(deprecated_rules, 12) != 0)
12263 7 custom_subscreen[2].objects[i].d3=1;
12264 else
12265 16 custom_subscreen[2].objects[i].d3=0;
12266
12267 23 break;
12268 }
12269
12270 default:
12271 368 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12272 368 break;
12273 }
12274 460 }
12275
12276 23 custom_subscreen[2].ss_type=sstPASSIVE;
12277 23 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12278 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12279 23 tempsub = default_subscreen_passive[tempsubscreen][1];
12280
12281
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 460 times.
✓ Branch 2 taken 437 times.
✓ Branch 3 taken 23 times.
460 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12282 {
12283
3/3
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 345 times.
✓ Branch 2 taken 23 times.
437 switch(tempsub[i].type)
12284 {
12285 case ssoTEXT:
12286 case ssoTEXTBOX:
12287 case ssoCURRENTITEMTEXT:
12288 case ssoCURRENTITEMCLASSTEXT:
12289
1/4
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
69 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12290
12291 69 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12292 69 custom_subscreen[3].objects[i].dp1 = NULL;
12293 69 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12294 69 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12295 69 break;
12296
12297 case ssoLIFEMETER:
12298 {
12299 23 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12300
12301
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(get_bit(deprecated_rules, 12) != 0)
12302 7 custom_subscreen[3].objects[i].d3=1;
12303 else
12304 16 custom_subscreen[3].objects[i].d3=0;
12305
12306 23 break;
12307 }
12308
12309 default:
12310 345 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12311 345 break;
12312 }
12313 437 }
12314
12315 23 custom_subscreen[3].ss_type=sstPASSIVE;
12316 23 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12317 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12318 23 break;
12319 }
12320
12321 case ssdtZ3:
12322 {
12323 tempsub = z3_active_a;
12324 int32_t i;
12325
12326 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12327 {
12328 switch(tempsub[i].type)
12329 {
12330 case ssoTEXT:
12331 case ssoTEXTBOX:
12332 case ssoCURRENTITEMTEXT:
12333 case ssoCURRENTITEMCLASSTEXT:
12334 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12335
12336 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12337 custom_subscreen[0].objects[i].dp1 = NULL;
12338 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12339 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12340 break;
12341
12342 case ssoLIFEMETER:
12343 {
12344 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12345
12346 if(get_bit(deprecated_rules, 12) != 0)
12347 custom_subscreen[0].objects[i].d3=1;
12348 else
12349 custom_subscreen[0].objects[i].d3=0;
12350
12351 break;
12352 }
12353
12354 default:
12355 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12356 break;
12357 }
12358 }
12359
12360 custom_subscreen[0].ss_type=sstACTIVE;
12361 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12362 tempsub = z3_active_ab;
12363
12364 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12365 {
12366 switch(tempsub[i].type)
12367 {
12368 case ssoTEXT:
12369 case ssoTEXTBOX:
12370 case ssoCURRENTITEMTEXT:
12371 case ssoCURRENTITEMCLASSTEXT:
12372 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12373
12374 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12375 custom_subscreen[1].objects[i].dp1 = NULL;
12376 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12377 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12378 break;
12379
12380 case ssoLIFEMETER:
12381 {
12382 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12383
12384 if(get_bit(deprecated_rules, 12) != 0)
12385 custom_subscreen[1].objects[i].d3=1;
12386 else
12387 custom_subscreen[1].objects[i].d3=0;
12388
12389 break;
12390 }
12391
12392 default:
12393 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12394 break;
12395 }
12396 }
12397
12398 custom_subscreen[1].ss_type=sstACTIVE;
12399 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12400 tempsub = z3_passive_a;
12401
12402 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12403 {
12404 switch(tempsub[i].type)
12405 {
12406 case ssoTEXT:
12407 case ssoTEXTBOX:
12408 case ssoCURRENTITEMTEXT:
12409 case ssoCURRENTITEMCLASSTEXT:
12410 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12411
12412 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12413 custom_subscreen[2].objects[i].dp1 = NULL;
12414 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12415 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12416 break;
12417
12418 case ssoLIFEMETER:
12419 {
12420 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12421
12422 if(get_bit(deprecated_rules, 12) != 0)
12423 custom_subscreen[2].objects[i].d3=1;
12424 else
12425 custom_subscreen[2].objects[i].d3=0;
12426
12427 break;
12428 }
12429
12430 default:
12431 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12432 break;
12433 }
12434 }
12435
12436 custom_subscreen[2].ss_type=sstPASSIVE;
12437 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12438 tempsub = z3_passive_ab;
12439
12440 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12441 {
12442 switch(tempsub[i].type)
12443 {
12444 case ssoTEXT:
12445 case ssoTEXTBOX:
12446 case ssoCURRENTITEMTEXT:
12447 case ssoCURRENTITEMCLASSTEXT:
12448 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12449
12450 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12451 custom_subscreen[3].objects[i].dp1 = NULL;
12452 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12453 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12454 break;
12455
12456 case ssoLIFEMETER:
12457 {
12458 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12459
12460 if(get_bit(deprecated_rules, 12) != 0)
12461 custom_subscreen[3].objects[i].d3=1;
12462 else
12463 custom_subscreen[3].objects[i].d3=0;
12464
12465 break;
12466 }
12467
12468 default:
12469 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12470 break;
12471 }
12472 }
12473
12474 custom_subscreen[3].ss_type=sstPASSIVE;
12475 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12476 break;
12477 }
12478 }
12479
12480
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 92 times.
115 for(int32_t i=0; i<4; ++i)
12481 {
12482 92 purge_blank_subscreen_objects(&custom_subscreen[i]);
12483 92 }
12484
12485 23 return 0;
12486 }
12487
12488 extern script_data *ffscripts[NUMSCRIPTFFC];
12489 extern script_data *itemscripts[NUMSCRIPTITEM];
12490 extern script_data *guyscripts[NUMSCRIPTGUYS];
12491 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12492 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12493 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12494 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12495 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12496 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12497 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12498 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12499 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12500 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12501 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12502
12503
12504
12505 105 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12506 {
12507 int32_t dummy;
12508 105 word s_version=0, s_cversion=0, zmeta_version=0;
12509 105 byte numscripts=0;
12510 105 numscripts=numscripts; //to avoid unused variables warnings
12511 int32_t ret;
12512
12513 //section version info
12514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
12515 {
12516 return qe_invalid;
12517 }
12518
12519 105 FFCore.quest_format[vFFScript] = s_version;
12520
12521
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
12522 {
12523 return qe_invalid;
12524 }
12525
12526
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version >= 18)
12527 {
12528
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetw(&zmeta_version,f,true))
12529 {
12530 return qe_invalid;
12531 }
12532 29 }
12533
12534 //al_trace("Scripts version %d\n", s_version);
12535 //section size
12536
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
12537 {
12538 return qe_invalid;
12539 }
12540
12541 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12542 105 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12543 105 temp_ffscript_version = s_version;
12544 //miscQdata *the_misc;
12545
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12546 105 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12547
12548 //finally... section data
12549
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 105 times.
53865 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12550 {
12551 53760 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12552
12553
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(ret != 0) return qe_invalid;
12554 53760 }
12555
12556 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12557 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12558 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12559 * there was a version bump a week before a change that broke stuff.
12560 */
12561
6/8
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29 times.
✓ Branch 7 taken 76 times.
105 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12562 {
12563 76 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12564 76 }
12565
3/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
105 if(s_version < 19 && keepdata)
12566 {
12567 76 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12568 76 }
12569
12570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version > 1)
12571 {
12572
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12573 {
12574 26880 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12575
12576
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(ret != 0) return qe_invalid;
12577 26880 }
12578
12579
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12580 {
12581 26880 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12582
12583
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(ret != 0) return qe_invalid;
12584 26880 }
12585
12586
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12587 {
12588 26880 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12589
12590
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(ret != 0) return qe_invalid;
12591 26880 }
12592
12593
12594
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12595 {
12596 26880 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12597
12598
1/2
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
26880 if(ret != 0) return qe_invalid;
12599 26880 }
12600
12601
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if(s_version > 16)
12602 {
12603
2/2
✓ Branch 0 taken 232 times.
✓ Branch 1 taken 29 times.
261 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12604 {
12605 232 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12606
12607
1/2
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
232 if(ret != 0) return qe_invalid;
12608 232 }
12609 29 }
12610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 else if(s_version > 13)
12611 {
12612 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12613 {
12614 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12615
12616 if(ret != 0) return qe_invalid;
12617 }
12618
12619 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12620 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12621
12622 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12623 }
12624
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 else if(s_version > 4)
12625 {
12626
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12627 {
12628 304 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12629
12630
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(ret != 0) return qe_invalid;
12631 304 }
12632
12633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12634
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12635
12636
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12637
12638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12639
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12640
12641
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12642
12643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12644
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_F6];
12645
12646
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12647
12648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12649
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12650
12651
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12652 76 }
12653 else
12654 {
12655 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12656 {
12657 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12658
12659 if(ret != 0) return qe_invalid;
12660 }
12661
12662 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12663 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12664
12665 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12666
12667 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12668 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12669
12670 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12671
12672 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12673 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12674
12675 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12676
12677 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12678 delete globalscripts[GLOBAL_SCRIPT_F6];
12679
12680 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12681
12682 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12683 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12684
12685 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12686 }
12687
12688
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if(s_version > 10) //expanded the number of Player scripts to 5.
12689 {
12690
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 29 times.
174 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12691 {
12692 145 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12693
12694
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 if(ret != 0) return qe_invalid;
12695 145 }
12696 29 }
12697 else
12698 {
12699
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 76 times.
304 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12700 {
12701 228 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12702
12703
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(ret != 0) return qe_invalid;
12704 228 }
12705
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(playerscripts[3] != NULL)
12706
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 delete playerscripts[3];
12707
12708
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 playerscripts[3] = new script_data();
12709
12710
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(playerscripts[4] != NULL)
12711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 delete playerscripts[4];
12712
12713
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 playerscripts[4] = new script_data();
12714 }
12715
3/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
105 if(s_version > 8 && s_version < 10)
12716 {
12717
12718 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12719 {
12720 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12721
12722 if(ret != 0) return qe_invalid;
12723 }
12724 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12725 {
12726 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12727
12728 if(ret != 0) return qe_invalid;
12729 }
12730
12731 }
12732
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version >= 10)
12733 {
12734
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12735 {
12736 7424 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12737
12738
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(ret != 0) return qe_invalid;
12739 7424 }
12740
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12741 {
12742 7424 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12743
12744
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(ret != 0) return qe_invalid;
12745 7424 }
12746
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12747 {
12748 7424 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12749
12750
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(ret != 0) return qe_invalid;
12751 7424 }
12752
12753 29 }
12754
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version >=12)
12755 {
12756
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12757 {
12758 7424 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12759
12760
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if(ret != 0) return qe_invalid;
12761 7424 }
12762 29 }
12763
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version >=15)
12764 {
12765
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 29 times.
14877 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12766 {
12767 14848 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12768
12769
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(ret != 0) return qe_invalid;
12770 14848 }
12771 29 }
12772
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version >19)
12773 {
12774 29 word numgenscripts = NUMSCRIPTSGENERIC;
12775
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetw(&numgenscripts,f,true))
12776 {
12777 return qe_invalid;
12778 }
12779
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 29 times.
14877 for(int32_t i = 0; i < numgenscripts; i++)
12780 {
12781 14848 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12782
12783
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(ret != 0) return qe_invalid;
12784 14848 }
12785 29 }
12786
12787 /*
12788 else //Is this trip really necessary?
12789 {
12790 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12791 {
12792
12793 ewpnscripts[i] = NULL;
12794 }
12795 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12796 {
12797 dmapscripts[i] = NULL;
12798 }
12799 }
12800 */
12801
12802 105 }
12803
12804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version > 2)
12805 {
12806 int32_t bufsize;
12807 105 p_igetl(&bufsize, f, true);
12808 105 char * buf = new char[bufsize+1];
12809 105 pfread(buf, bufsize, f, true);
12810 105 buf[bufsize]=0;
12811
12812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata)
12813
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 zScript = string(buf);
12814
12815
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 delete[] buf;
12816 word numffcbindings;
12817 105 p_igetw(&numffcbindings, f, true);
12818
12819
2/2
✓ Branch 0 taken 1501 times.
✓ Branch 1 taken 105 times.
1606 for(int32_t i=0; i<numffcbindings; i++)
12820 {
12821 word id;
12822 1501 p_igetw(&id, f, true);
12823 1501 p_igetl(&bufsize, f, true);
12824 1501 buf = new char[bufsize+1];
12825 1501 pfread(buf, bufsize, f, true);
12826 1501 buf[bufsize]=0;
12827
12828 //fix for buggy older saved quests -DD
12829
2/4
✓ Branch 0 taken 1501 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1501 times.
1501 if(keepdata && id < NUMSCRIPTFFC-1)
12830 1501 ffcmap[id].scriptname = buf;
12831
12832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1501 times.
1501 delete[] buf;
12833 1501 }
12834
12835 word numglobalbindings;
12836 105 p_igetw(&numglobalbindings, f, true);
12837
12838
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 105 times.
526 for(int32_t i=0; i<numglobalbindings; i++)
12839 {
12840 word id;
12841 421 p_igetw(&id, f, true);
12842 421 p_igetl(&bufsize, f, true);
12843 421 buf = new char[bufsize+1];
12844 421 pfread(buf, bufsize, f, true);
12845 421 buf[bufsize]=0;
12846
12847 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12848 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12849 // Ignore these. -DD
12850
4/6
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159 times.
✓ Branch 5 taken 262 times.
421 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12851 {
12852 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12853
1/2
✓ Branch 0 taken 262 times.
✗ Branch 1 not taken.
262 if(strcmp(buf,"~Continue") == 0)
12854 {
12855 globalmap[id].scriptname = "";
12856
12857 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12858 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12859 }
12860 else
12861 {
12862 262 globalmap[id].scriptname = buf;
12863 }
12864 262 }
12865
12866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 delete[] buf;
12867 421 }
12868
12869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version > 3)
12870 {
12871 word numitembindings;
12872 105 p_igetw(&numitembindings, f, true);
12873
12874
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 105 times.
203 for(int32_t i=0; i<numitembindings; i++)
12875 {
12876 word id;
12877 98 p_igetw(&id, f, true);
12878 98 p_igetl(&bufsize, f, true);
12879 98 buf = new char[bufsize+1];
12880 98 pfread(buf, bufsize, f, true);
12881 98 buf[bufsize]=0;
12882
12883 //fix this too
12884
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
98 if(keepdata && id <NUMSCRIPTITEM-1)
12885 98 itemmap[id].scriptname = buf;
12886
12887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 delete[] buf;
12888 98 }
12889 105 }
12890 //(v9+)
12891
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version > 8)
12892 {
12893 //npc scripts
12894 word numnpcbindings;
12895 29 p_igetw(&numnpcbindings, f, true);
12896
12897
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 29 times.
41 for(int32_t i=0; i<numnpcbindings; i++)
12898 {
12899 word id;
12900 12 p_igetw(&id, f, true);
12901 12 p_igetl(&bufsize, f, true);
12902 12 buf = new char[bufsize+1];
12903 12 pfread(buf, bufsize, f, true);
12904 12 buf[bufsize]=0;
12905
12906 //fix this too
12907
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(keepdata && id <NUMSCRIPTGUYS-1)
12908 12 npcmap[id].scriptname = buf;
12909
12910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12911 12 }
12912 //lweapon
12913 word numlwpnbindings;
12914 29 p_igetw(&numlwpnbindings, f, true);
12915
12916
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 29 times.
71 for(int32_t i=0; i<numlwpnbindings; i++)
12917 {
12918 word id;
12919 42 p_igetw(&id, f, true);
12920 42 p_igetl(&bufsize, f, true);
12921 42 buf = new char[bufsize+1];
12922 42 pfread(buf, bufsize, f, true);
12923 42 buf[bufsize]=0;
12924
12925 //fix this too
12926
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12927 42 lwpnmap[id].scriptname = buf;
12928
12929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
12930 42 }
12931 //eweapon
12932 word numewpnbindings;
12933 29 p_igetw(&numewpnbindings, f, true);
12934
12935
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 29 times.
92 for(int32_t i=0; i<numewpnbindings; i++)
12936 {
12937 word id;
12938 63 p_igetw(&id, f, true);
12939 63 p_igetl(&bufsize, f, true);
12940 63 buf = new char[bufsize+1];
12941 63 pfread(buf, bufsize, f, true);
12942 63 buf[bufsize]=0;
12943
12944 //fix this too
12945
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12946 63 ewpnmap[id].scriptname = buf;
12947
12948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12949 63 }
12950 //hero
12951 word numherobindings;
12952 29 p_igetw(&numherobindings, f, true);
12953
12954
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 29 times.
34 for(int32_t i=0; i<numherobindings; i++)
12955 {
12956 word id;
12957 5 p_igetw(&id, f, true);
12958 5 p_igetl(&bufsize, f, true);
12959 5 buf = new char[bufsize+1];
12960 5 pfread(buf, bufsize, f, true);
12961 5 buf[bufsize]=0;
12962
12963 //fix this too
12964
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if(keepdata && id <NUMSCRIPTPLAYER-1)
12965 5 playermap[id].scriptname = buf;
12966
12967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 delete[] buf;
12968 5 }
12969 //dmaps
12970 word numdmapbindings;
12971 29 p_igetw(&numdmapbindings, f, true);
12972
12973
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 29 times.
55 for(int32_t i=0; i<numdmapbindings; i++)
12974 {
12975 word id;
12976 26 p_igetw(&id, f, true);
12977 26 p_igetl(&bufsize, f, true);
12978 26 buf = new char[bufsize+1];
12979 26 pfread(buf, bufsize, f, true);
12980 26 buf[bufsize]=0;
12981
12982 //fix this too
12983
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26 times.
26 if(keepdata && id <NUMSCRIPTSDMAP-1)
12984 26 dmapmap[id].scriptname = buf;
12985
12986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 delete[] buf;
12987 26 }
12988 //screen
12989 word numscreenbindings;
12990 29 p_igetw(&numscreenbindings, f, true);
12991
12992
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 29 times.
47 for(int32_t i=0; i<numscreenbindings; i++)
12993 {
12994 word id;
12995 18 p_igetw(&id, f, true);
12996 18 p_igetl(&bufsize, f, true);
12997 18 buf = new char[bufsize+1];
12998 18 pfread(buf, bufsize, f, true);
12999 18 buf[bufsize]=0;
13000
13001 //fix this too
13002
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 if(keepdata && id <NUMSCRIPTSDMAP-1)
13003 18 screenmap[id].scriptname = buf;
13004
13005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 delete[] buf;
13006 18 }
13007 29 }
13008
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version > 11)
13009 {
13010 word numspritebindings;
13011 29 p_igetw(&numspritebindings, f, true);
13012
13013
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 29 times.
39 for(int32_t i=0; i<numspritebindings; i++)
13014 {
13015 word id;
13016 10 p_igetw(&id, f, true);
13017 10 p_igetl(&bufsize, f, true);
13018 10 buf = new char[bufsize+1];
13019 10 pfread(buf, bufsize, f, true);
13020 10 buf[bufsize]=0;
13021
13022 //fix this too
13023
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(keepdata && id <NUMSCRIPTSDMAP-1)
13024 10 itemspritemap[id].scriptname = buf;
13025
13026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
13027 10 }
13028 29 }
13029
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version >= 15)
13030 {
13031 word numcombobindings;
13032 29 p_igetw(&numcombobindings, f, true);
13033
13034
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 29 times.
52 for(int32_t i=0; i<numcombobindings; i++)
13035 {
13036 word id;
13037 23 p_igetw(&id, f, true);
13038 23 p_igetl(&bufsize, f, true);
13039 23 buf = new char[bufsize+1];
13040 23 pfread(buf, bufsize, f, true);
13041 23 buf[bufsize]=0;
13042
13043 //fix this too
13044
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
13045 23 comboscriptmap[id].scriptname = buf;
13046
13047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 delete[] buf;
13048 23 }
13049 29 }
13050
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 29 times.
105 if(s_version > 19)
13051 {
13052 word numgenericbindings;
13053 29 p_igetw(&numgenericbindings, f, true);
13054
13055
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 29 times.
42 for(int32_t i=0; i<numgenericbindings; i++)
13056 {
13057 word id;
13058 13 p_igetw(&id, f, true);
13059 13 p_igetl(&bufsize, f, true);
13060 13 buf = new char[bufsize+1];
13061 13 pfread(buf, bufsize, f, true);
13062 13 buf[bufsize]=0;
13063
13064 //fix this too
13065
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(keepdata && id <NUMSCRIPTSGENERIC-1)
13066 13 genericmap[id].scriptname = buf;
13067
13068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 delete[] buf;
13069 13 }
13070 29 }
13071 105 }
13072
13073 105 return 0;
13074 105 }
13075
13076 114 void reset_scripts()
13077 {
13078 //OK, who spaced this? ;)
13079
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
13080 {
13081
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58368 times.
58368 if(ffscripts[i]!=NULL) delete ffscripts[i];
13082 58368 }
13083
13084
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13085 {
13086
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(itemscripts[i]!=NULL) delete itemscripts[i];
13087 29184 }
13088
13089
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13090 {
13091
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(guyscripts[i]!=NULL) delete guyscripts[i];
13092 29184 }
13093
13094
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13095 {
13096
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
13097 29184 }
13098
13099
13100
13101
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13102 {
13103
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(screenscripts[i]!=NULL) delete screenscripts[i];
13104 29184 }
13105
13106
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 114 times.
1026 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13107 {
13108
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 912 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 912 times.
912 if(globalscripts[i]!=NULL) delete globalscripts[i];
13109 912 }
13110
13111
2/2
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 114 times.
684 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13112 {
13113
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 570 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 570 times.
570 if(playerscripts[i]!=NULL) delete playerscripts[i];
13114 570 }
13115
13116
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13117 {
13118
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
13119 29184 }
13120
13121
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13122 {
13123
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
13124 29184 }
13125
13126
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13127 {
13128
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
13129 29184 }
13130
13131
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13132 {
13133
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
13134 29184 }
13135
13136
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13137 {
13138
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58368 times.
58368 if(comboscripts[i]!=NULL) delete comboscripts[i];
13139 58368 }
13140
13141 114 next_script_data_debug_id = 0;
13142
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
13143 {
13144
3/4
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 38912 times.
✓ Branch 2 taken 38912 times.
✗ Branch 3 not taken.
58368 if(genericscripts[i]!=NULL) delete genericscripts[i];
13145
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 genericscripts[i] = new script_data();
13146 58368 }
13147
13148
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
13149 {
13150
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 ffscripts[i] = new script_data();
13151 58368 }
13152
13153
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13154 {
13155
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 itemscripts[i] = new script_data();
13156 29184 }
13157
13158
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13159 {
13160
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 guyscripts[i] = new script_data();
13161 29184 }
13162
13163
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13164 {
13165
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 wpnscripts[i] = new script_data();
13166 29184 }
13167
13168
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13169 {
13170
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 screenscripts[i] = new script_data();
13171 29184 }
13172
13173
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 114 times.
1026 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13174 {
13175
1/2
✓ Branch 0 taken 912 times.
✗ Branch 1 not taken.
912 globalscripts[i] = new script_data();
13176 912 }
13177
13178
2/2
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 114 times.
684 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13179 {
13180
1/2
✓ Branch 0 taken 570 times.
✗ Branch 1 not taken.
570 playerscripts[i] = new script_data();
13181 570 }
13182
13183
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13184 {
13185
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 lwpnscripts[i] = new script_data();
13186 29184 }
13187
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13188 {
13189
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 ewpnscripts[i] = new script_data();
13190 29184 }
13191
13192
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13193 {
13194
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 dmapscripts[i] = new script_data();
13195 29184 }
13196
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13197 {
13198
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 itemspritescripts[i] = new script_data();
13199 29184 }
13200
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13201 {
13202
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 comboscripts[i] = new script_data();
13203 58368 }
13204 114 }
13205
13206 extern script_command command_list[];
13207 221581 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13208 {
13209 //Please also update loadquest() when modifying this method -DD
13210 221581 char b33[34] = {0};
13211 221581 b33[33] = 0;
13212 221581 ffscript temp_script;
13213 221581 int32_t num_commands=1000;
13214
13215
1/2
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
221581 if(s_version>=2)
13216 {
13217
2/4
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 221581 times.
✗ Branch 3 not taken.
221581 if(!p_igetl(&num_commands,f,true))
13218 {
13219 return qe_invalid;
13220 }
13221 221581 }
13222
13223
1/2
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
221581 if(keepdata)
13224 {
13225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221581 times.
221581 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221581 times.
221581 delete (*script);
13227
2/4
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 221581 times.
✗ Branch 3 not taken.
221581 (*script) = new script_data(num_commands);
13228 221581 }
13229
2/2
✓ Branch 0 taken 104313 times.
✓ Branch 1 taken 117268 times.
221581 if(s_version >= 16)
13230 {
13231
1/2
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
104313 zasm_meta temp_meta;
13232
13233
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13234 {
13235 return qe_invalid;
13236 }
13237
13238
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.meta_v),f,true))
13239 {
13240 return qe_invalid;
13241 }
13242
13243
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13244 {
13245 return qe_invalid;
13246 }
13247
13248
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_getc(&(temp_meta.script_type),f,true))
13249 {
13250 return qe_invalid;
13251 }
13252
13253
2/2
✓ Branch 0 taken 834504 times.
✓ Branch 1 taken 104313 times.
938817 for(int32_t q = 0; q < 8; ++q)
13254 {
13255
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 776952 times.
834504 if(zmeta_version < 3)
13256 {
13257
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
13258 {
13259
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f,true))
13260 {
13261 return qe_invalid;
13262 }
13263 1899216 }
13264
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
13265 57552 }
13266 else
13267 {
13268
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13269 {
13270 return qe_invalid;
13271 }
13272 }
13273 834504 }
13274
13275
2/2
✓ Branch 0 taken 104313 times.
✓ Branch 1 taken 834504 times.
938817 for(int32_t q = 0; q < 8; ++q)
13276 {
13277
2/4
✓ Branch 0 taken 834504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 834504 times.
✗ Branch 3 not taken.
834504 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13278 {
13279 return qe_invalid;
13280 }
13281 834504 }
13282
13283
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_getc(&(temp_meta.flags),f,true))
13284 {
13285 return qe_invalid;
13286 }
13287
13288
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13289 {
13290 return qe_invalid;
13291 }
13292
13293
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13294 {
13295 return qe_invalid;
13296 }
13297
13298
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13299 {
13300 return qe_invalid;
13301 }
13302
13303
2/4
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104313 times.
✗ Branch 3 not taken.
104313 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13304 {
13305 return qe_invalid;
13306 }
13307
13308
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 97119 times.
104313 if(zmeta_version == 2)
13309 {
13310
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13311 {
13312
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f,true))
13313 {
13314 return qe_invalid;
13315 }
13316 237402 }
13317
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
13318
13319
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13320 {
13321
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f,true))
13322 {
13323 return qe_invalid;
13324 }
13325 237402 }
13326
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
13327 7194 }
13328
1/2
✓ Branch 0 taken 97119 times.
✗ Branch 1 not taken.
97119 else if(zmeta_version > 2)
13329 {
13330
2/4
✓ Branch 0 taken 97119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97119 times.
✗ Branch 3 not taken.
97119 if(!p_getcstr(&temp_meta.script_name,f,true))
13331 return qe_invalid;
13332
2/4
✓ Branch 0 taken 97119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97119 times.
✗ Branch 3 not taken.
97119 if(!p_getcstr(&temp_meta.author,f,true))
13333 return qe_invalid;
13334 97119 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13335
2/2
✓ Branch 0 taken 971190 times.
✓ Branch 1 taken 97119 times.
1068309 for(auto q = 0; q < num_meta_attrib; ++q)
13336 {
13337
2/4
✓ Branch 0 taken 971190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 971190 times.
✗ Branch 3 not taken.
971190 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13338 return qe_invalid;
13339
2/4
✓ Branch 0 taken 971190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 971190 times.
✗ Branch 3 not taken.
971190 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13340 return qe_invalid;
13341 971190 }
13342
2/2
✓ Branch 0 taken 776952 times.
✓ Branch 1 taken 97119 times.
874071 for(auto q = 0; q < 8; ++q)
13343 {
13344
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13345 return qe_invalid;
13346
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13347 return qe_invalid;
13348 776952 }
13349
2/2
✓ Branch 0 taken 776952 times.
✓ Branch 1 taken 97119 times.
874071 for(auto q = 0; q < 8; ++q)
13350 {
13351
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13352 return qe_invalid;
13353
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13354 return qe_invalid;
13355 776952 }
13356
2/2
✓ Branch 0 taken 1553904 times.
✓ Branch 1 taken 97119 times.
1651023 for(auto q = 0; q < 16; ++q)
13357 {
13358
2/4
✓ Branch 0 taken 1553904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1553904 times.
✗ Branch 3 not taken.
1553904 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13359 return qe_invalid;
13360
2/4
✓ Branch 0 taken 1553904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1553904 times.
✗ Branch 3 not taken.
1553904 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13361 return qe_invalid;
13362 1553904 }
13363 97119 }
13364
2/2
✓ Branch 0 taken 97119 times.
✓ Branch 1 taken 7194 times.
104313 if(zmeta_version > 3)
13365 {
13366
2/2
✓ Branch 0 taken 776952 times.
✓ Branch 1 taken 97119 times.
874071 for(auto q = 0; q < 8; ++q)
13367 {
13368
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getcstr(&temp_meta.initd[q],f,true))
13369 return qe_invalid;
13370
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13371 return qe_invalid;
13372 776952 }
13373
2/2
✓ Branch 0 taken 776952 times.
✓ Branch 1 taken 97119 times.
874071 for(auto q = 0; q < 8; ++q)
13374 {
13375
2/4
✓ Branch 0 taken 776952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 776952 times.
✗ Branch 3 not taken.
776952 if(!p_getc(&temp_meta.initd_type[q],f,true))
13376 return qe_invalid;
13377 776952 }
13378 97119 }
13379 else
13380 {
13381
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13382 {
13383
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
13384 57552 }
13385 }
13386
13387
1/2
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
104313 if(keepdata)
13388
1/2
✓ Branch 0 taken 104313 times.
✗ Branch 1 not taken.
104313 (*script)->meta = temp_meta;
13389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104313 times.
104313 }
13390
13391
1/2
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
221581 temp_script.clear();
13392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21665137 times.
21665137 for(int32_t j=0; j<num_commands; j++)
13393 {
13394
2/4
✓ Branch 0 taken 21665137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21665137 times.
✗ Branch 3 not taken.
21665137 if(!p_igetw(&(temp_script.command),f,true))
13395 {
13396 return qe_invalid;
13397 }
13398
13399
2/2
✓ Branch 0 taken 21443556 times.
✓ Branch 1 taken 221581 times.
21665137 if(temp_script.command == 0xFFFF)
13400 {
13401
1/2
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
221581 if(keepdata)
13402
1/2
✓ Branch 0 taken 221581 times.
✗ Branch 1 not taken.
221581 (*script)->zasm[j].clear();
13403 221581 break;
13404 }
13405 else
13406 {
13407
2/4
✓ Branch 0 taken 21443556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21443556 times.
✗ Branch 3 not taken.
21443556 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13408 {
13409 return qe_invalid;
13410 }
13411
13412
2/4
✓ Branch 0 taken 21443556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21443556 times.
✗ Branch 3 not taken.
21443556 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13413 {
13414 return qe_invalid;
13415 }
13416
13417
2/2
✓ Branch 0 taken 771761 times.
✓ Branch 1 taken 20671795 times.
21443556 if(s_version >= 21)
13418 {
13419 771761 uint32_t sz = 0;
13420
2/4
✓ Branch 0 taken 771761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 771761 times.
✗ Branch 3 not taken.
771761 if(!p_igetl(&sz,f,keepdata))
13421 {
13422 return qe_invalid;
13423 }
13424
2/2
✓ Branch 0 taken 2900 times.
✓ Branch 1 taken 768861 times.
771761 if(sz) //string found
13425 {
13426
1/2
✓ Branch 0 taken 2900 times.
✗ Branch 1 not taken.
2900 temp_script.strptr = new std::string();
13427 char dummy;
13428
2/2
✓ Branch 0 taken 227192 times.
✓ Branch 1 taken 2900 times.
230092 for(size_t q = 0; q < sz; ++q)
13429 {
13430
2/4
✓ Branch 0 taken 227192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 227192 times.
✗ Branch 3 not taken.
227192 if(!p_getc(&dummy,f,keepdata))
13431 {
13432 return qe_invalid;
13433 }
13434
1/2
✓ Branch 0 taken 227192 times.
✗ Branch 1 not taken.
227192 temp_script.strptr->push_back(dummy);
13435 227192 }
13436 2900 }
13437
2/4
✓ Branch 0 taken 771761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 771761 times.
✗ Branch 3 not taken.
771761 if(!p_igetl(&sz,f,keepdata))
13438 {
13439 return qe_invalid;
13440 }
13441
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 771660 times.
771761 if(sz) //vector found
13442 {
13443
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 temp_script.vecptr = new std::vector<int32_t>();
13444 int32_t dummy;
13445
2/2
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 101 times.
1588 for(size_t q = 0; q < sz; ++q)
13446 {
13447
2/4
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1487 times.
✗ Branch 3 not taken.
1487 if(!p_igetl(&dummy,f,keepdata))
13448 {
13449 return qe_invalid;
13450 }
13451
1/2
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
1487 temp_script.vecptr->push_back(dummy);
13452 1487 }
13453 101 }
13454 771761 }
13455
13456
1/2
✓ Branch 0 taken 21443556 times.
✗ Branch 1 not taken.
21443556 if(keepdata)
13457 {
13458
1/2
✓ Branch 0 taken 21443556 times.
✗ Branch 1 not taken.
21443556 temp_script.give((*script)->zasm[j]);
13459 21443556 }
13460 }
13461
1/2
✓ Branch 0 taken 21443556 times.
✗ Branch 1 not taken.
21443556 temp_script.clear();
13462 21443556 }
13463
13464 221581 return 0;
13465 221581 }
13466
13467 extern SAMPLE customsfxdata[WAV_COUNT];
13468 extern uint8_t customsfxflag[WAV_COUNT>>3];
13469 extern int32_t sfxdat;
13470 extern DATAFILE *sfxdata;
13471 const char *old_sfx_string[Z35] =
13472 {
13473 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13474 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13475 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13476 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13477 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13478 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13479 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13480 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13481 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13482 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13483 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13484 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13485 };
13486 char *sfx_string[WAV_COUNT];
13487
13488 105 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13489 {
13490 //these are here to bypass compiler warnings about unused arguments
13491 105 Header=Header;
13492
13493 int32_t dummy;
13494 105 word s_version=0, s_cversion=0;
13495 //int32_t ret;
13496 SAMPLE temp_sample;
13497 105 temp_sample.loop_start=0;
13498 105 temp_sample.loop_end=0;
13499 105 temp_sample.param=0;
13500
13501 //section version info
13502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
13503 {
13504 return qe_invalid;
13505 }
13506
13507 105 FFCore.quest_format[vSFX] = s_version;
13508
13509 //al_trace("SFX version %d\n", s_version);
13510
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
13511 {
13512 return qe_invalid;
13513 }
13514
13515 //section size
13516
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
13517 {
13518 return qe_invalid;
13519 }
13520
13521 /* HIGHLY UNORTHODOX UPDATING THING, by L
13522 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13523 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13524 * changing from 1 to 2.
13525 */
13526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
105 if(s_version < 2 && keepdata)
13527 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13528
13529 /* End highly unorthodox updating thing */
13530
13531 105 int32_t wavcount = WAV_COUNT;
13532
13533
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(s_version < 6)
13534 wavcount = 128;
13535
13536 uint8_t tempflag[WAV_COUNT>>3];
13537
13538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version < 4)
13539 {
13540 memset(tempflag, 0xFF, WAV_COUNT>>3);
13541 }
13542 else
13543 {
13544
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(s_version < 6)
13545 memset(tempflag, 0, WAV_COUNT>>3);
13546
13547
2/2
✓ Branch 0 taken 3360 times.
✓ Branch 1 taken 105 times.
3465 for(int32_t i=0; i<(wavcount>>3); i++)
13548 {
13549 3360 p_getc(&tempflag[i], f, true);
13550 3360 }
13551
13552 }
13553
13554
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(s_version>4)
13555 {
13556
2/2
✓ Branch 0 taken 26775 times.
✓ Branch 1 taken 105 times.
26880 for(int32_t i=1; i<WAV_COUNT; i++)
13557 {
13558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26775 times.
26775 if(keepdata)
13559 {
13560 26775 sprintf(sfx_string[i],"s%03d",i);
13561
13562
2/2
✓ Branch 0 taken 20475 times.
✓ Branch 1 taken 6300 times.
26775 if((i<Z35))
13563 6300 strcpy(sfx_string[i], old_sfx_string[i-1]);
13564 26775 }
13565
13566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26775 times.
26775 if(i>=wavcount)
13567 continue;
13568
2/2
✓ Branch 0 taken 2513 times.
✓ Branch 1 taken 24262 times.
26775 if(get_bit(tempflag, i-1))
13569 {
13570 char tempname[36];
13571
13572
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!pfread(tempname, 36, f, keepdata))
13573 {
13574 return qe_invalid;
13575 }
13576
13577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2513 times.
2513 if(keepdata)
13578 {
13579 2513 strcpy(sfx_string[i], tempname);
13580 2513 sfx_string[i][35] = 0; //Force NULL Termination
13581 2513 }
13582 2513 }
13583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24262 times.
24262 else if(keepdata)
13584 {
13585 24262 sprintf(sfx_string[i],"s%03d",i);
13586
13587
2/2
✓ Branch 0 taken 19744 times.
✓ Branch 1 taken 4518 times.
24262 if(i<Z35)
13588 4518 strcpy(sfx_string[i], old_sfx_string[i-1]);
13589 24262 sfx_string[i][35] = 0; //Force NULL Termination
13590 24262 }
13591 26775 }
13592 105 }
13593 else
13594 {
13595 if(keepdata)
13596 {
13597 for(int32_t i=1; i<WAV_COUNT; i++)
13598 {
13599 sprintf(sfx_string[i],"s%03d",i);
13600
13601 if(i<Z35)
13602 strcpy(sfx_string[i], old_sfx_string[i-1]);
13603 }
13604 }
13605 }
13606
13607 //finally... section data
13608
2/2
✓ Branch 0 taken 26775 times.
✓ Branch 1 taken 105 times.
26880 for(int32_t i=1; i<wavcount; i++)
13609 {
13610
2/2
✓ Branch 0 taken 2513 times.
✓ Branch 1 taken 24262 times.
26775 if(get_bit(tempflag, i-1))
13611 {
13612
13613
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&dummy,f,true))
13614 {
13615 return qe_invalid;
13616 }
13617
13618 2513 (temp_sample.bits) = dummy;
13619
13620
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&dummy,f,true))
13621 {
13622 return qe_invalid;
13623 }
13624
13625 2513 (temp_sample.stereo) = dummy;
13626
13627
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&dummy,f,keepdata))
13628 {
13629 return qe_invalid;
13630 }
13631
13632 2513 (temp_sample.freq) = dummy;
13633
13634
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&dummy,f,keepdata))
13635 {
13636 return qe_invalid;
13637 }
13638
13639 2513 (temp_sample.priority) = dummy;
13640
13641
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&(temp_sample.len),f,true))
13642 {
13643 return qe_invalid;
13644 }
13645
13646
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13647 {
13648 return qe_invalid;
13649 }
13650
13651
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13652 {
13653 return qe_invalid;
13654 }
13655
13656
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(!p_igetl(&(temp_sample.param),f,keepdata))
13657 {
13658 return qe_invalid;
13659 }
13660
13661 // al_trace("F%i: L%i\n",i,temp_sample.len);
13662 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13663 2513 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13664 2513 temp_sample.data = calloc(len,1);
13665
13666
1/2
✓ Branch 0 taken 2513 times.
✗ Branch 1 not taken.
2513 if(s_version < 3)
13667 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13668
13669 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2513 times.
2513 if(s_version < 2)
13671 {
13672 if(!pfread(temp_sample.data, len,f,keepdata))
13673 {
13674 return qe_invalid;
13675 }
13676 }
13677 else
13678 {
13679 //re-endianfy the data
13680 2513 int32_t wordstoread = len / sizeof(word);
13681
13682
2/2
✓ Branch 0 taken 76164518 times.
✓ Branch 1 taken 2513 times.
76167031 for(int32_t j=0; j<wordstoread; j++)
13683 {
13684 word temp;
13685
13686
1/2
✓ Branch 0 taken 76164518 times.
✗ Branch 1 not taken.
76164518 if(!p_igetw(&temp, f, keepdata))
13687 {
13688 return qe_invalid;
13689 }
13690
13691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76164518 times.
76164518 if(keepdata)
13692 76164518 ((word *)temp_sample.data)[j] = temp;
13693 76164518 }
13694 }
13695 2513 }
13696
2/2
✓ Branch 0 taken 4518 times.
✓ Branch 1 taken 19744 times.
24262 else if(i < Z35)
13697 {
13698 4518 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13699 4518 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13700 4518 set_bit(tempflag, i-1, 1);
13701 4518 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13702 4518 temp_sample.data = calloc(len,1);
13703 4518 memcpy(temp_sample.data, datsamp->data, len);
13704 4518 }
13705 19744 else continue;
13706
13707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7031 times.
7031 if(keepdata)
13708 {
13709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7031 times.
7031 if(customsfxdata[i].data!=NULL)
13710 {
13711 // delete [] customsfxdata[i].data;
13712 7031 free(customsfxdata[i].data);
13713 7031 }
13714
13715 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13716 7031 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13717 7031 customsfxdata[i].data = calloc(len2,1);
13718 7031 customsfxdata[i].bits = temp_sample.bits;
13719 7031 customsfxdata[i].stereo = temp_sample.stereo;
13720 7031 customsfxdata[i].freq = temp_sample.freq;
13721 7031 customsfxdata[i].priority = temp_sample.priority;
13722 7031 customsfxdata[i].len = temp_sample.len;
13723 7031 customsfxdata[i].loop_start = temp_sample.loop_start;
13724 7031 customsfxdata[i].loop_end = temp_sample.loop_end;
13725 7031 customsfxdata[i].param = temp_sample.param;
13726 7031 int32_t cpylen = len2;
13727
13728
1/2
✓ Branch 0 taken 7031 times.
✗ Branch 1 not taken.
7031 if(s_version<3)
13729 {
13730 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13731 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13732 }
13733
13734 7031 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13735 7031 }
13736
13737 7031 free(temp_sample.data);
13738 7031 }
13739
13740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata)
13741 105 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13742
13743 105 sfxdat=0;
13744 105 return 0;
13745 105 }
13746
13747 114 void setupsfx()
13748 {
13749
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=1; i<WAV_COUNT; i++)
13750 {
13751 29070 sprintf(sfx_string[i],"s%03d",i);
13752
13753
2/2
✓ Branch 0 taken 22230 times.
✓ Branch 1 taken 6840 times.
29070 if(i<Z35)
13754 {
13755 6840 strcpy(sfx_string[i], old_sfx_string[i-1]);
13756 6840 }
13757
13758 29070 memset(customsfxflag, 0, WAV_COUNT>>3);
13759
13760 29070 int32_t j=i;
13761
13762
2/2
✓ Branch 0 taken 6954 times.
✓ Branch 1 taken 22116 times.
29070 if(i>Z35)
13763 {
13764 22116 i=Z35;
13765 22116 }
13766
13767 29070 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13768
13769
2/2
✓ Branch 0 taken 9690 times.
✓ Branch 1 taken 19380 times.
29070 if(customsfxdata[j].data!=NULL)
13770 {
13771 // delete [] customsfxdata[j].data;
13772 19380 free(customsfxdata[j].data);
13773 19380 }
13774
13775 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13776 29070 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13777 29070 customsfxdata[j].bits = temp_sample->bits;
13778 29070 customsfxdata[j].stereo = temp_sample->stereo;
13779 29070 customsfxdata[j].freq = temp_sample->freq;
13780 29070 customsfxdata[j].priority = temp_sample->priority;
13781 29070 customsfxdata[j].len = temp_sample->len;
13782 29070 customsfxdata[j].loop_start = temp_sample->loop_start;
13783 29070 customsfxdata[j].loop_end = temp_sample->loop_end;
13784 29070 customsfxdata[j].param = temp_sample->param;
13785 29070 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13786 29070 i=j;
13787 29070 }
13788 114 }
13789
13790 extern char *guy_string[eMAXGUYS];
13791 extern const char *old_guy_string[OLDMAXGUYS];
13792
13793 114 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13794 {
13795 dword dummy;
13796 word guy_cversion;
13797 114 word guyversion=0;
13798
13799
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version >= 0x193)
13800 {
13801 //section version info
13802
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&guyversion,f,true))
13803 {
13804 return qe_invalid;
13805 }
13806
13807 110 FFCore.quest_format[vGuys] = guyversion;
13808
13809 //al_trace("Guys version %d\n", guyversion);
13810
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&guy_cversion,f,true))
13811 {
13812 return qe_invalid;
13813 }
13814 110 al_trace("Guy CVersion is: %d\n", guy_cversion);
13815 //section size
13816
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
13817 {
13818 return qe_invalid;
13819 }
13820 110 }
13821
13822
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(guyversion > 3)
13823 {
13824
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 105 times.
53865 for(int32_t i=0; i<MAXGUYS; i++)
13825 {
13826 char tempname[64];
13827
13828 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13829 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13830
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53760 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13831 {
13832 memset(tempname, 0, sizeof(char)*64);
13833 sprintf(tempname, "e%03d", i);
13834 strcpy(guy_string[i], tempname);
13835
13836 continue;
13837 }
13838
13839
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!pfread(tempname, 64, f, keepdata))
13840 {
13841 return qe_invalid;
13842 }
13843
13844 // Don't retain names of uneditable enemy entries!
13845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(keepdata)
13846 {
13847 // for version upgrade to 2.5
13848
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53760 if(guyversion < 23 && i >= 177)
13849 {
13850 // some of the older builds have names such as 'zz123',
13851 // (this order gets messed up with some eXXX and some zzXXX)
13852 // so let's update to the newer naming convection. -Gleeok
13853 char tmpbuf[64];
13854 memset(tmpbuf, 0, sizeof(char)*64);
13855 sprintf(tmpbuf, "zz%03d", i);
13856
13857 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13858 {
13859 memset(tempname, 0, sizeof(char)*64);
13860 sprintf(tempname, "e%03d", i);
13861 }
13862 }
13863
13864
6/6
✓ Branch 0 taken 18585 times.
✓ Branch 1 taken 35175 times.
✓ Branch 2 taken 17640 times.
✓ Branch 3 taken 945 times.
✓ Branch 4 taken 14683 times.
✓ Branch 5 taken 2957 times.
53760 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13865 {
13866 50803 strcpy(guy_string[i], tempname);
13867 50803 }
13868 else
13869 {
13870 2957 strcpy(guy_string[i],old_guy_string[i]);
13871 }
13872 53760 }
13873 53760 }
13874 105 }
13875 else
13876 {
13877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
13878 {
13879
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<eMAXGUYS; i++)
13880 {
13881 4608 sprintf(guy_string[i],"zz%03d",i);
13882 4608 }
13883
13884
2/2
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 9 times.
1602 for(int32_t i=0; i<OLDMAXGUYS; i++)
13885 {
13886 1593 strcpy(guy_string[i],old_guy_string[i]);
13887 1593 }
13888 9 }
13889 }
13890
13891
13892 //finally... section data
13893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata)
13894 {
13895 114 init_guys(guyversion); //using default data for now...
13896
13897 // Goriya guy fix
13898
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13899 {
13900
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13901 {
13902 5 guysbuf[gGORIYA].tile=130;
13903 5 guysbuf[gGORIYA].e_tile=130;
13904 5 }
13905 9 }
13906 114 }
13907
13908
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(Header->zelda_version < 0x193)
13909 {
13910
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13911 {
13912 guysbuf[eDODONGO].cset=14;
13913 guysbuf[eDODONGO].bosspal=spDIG;
13914 }
13915 4 }
13916 // Not sure when this first changed, but it's necessary for 2.10, at least
13917 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13918 //2.10 Fixes
13919
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13920 {
13921 9 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13922 9 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13923 9 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13924 9 guysbuf[eCENT1].misc3 = 1;
13925 9 guysbuf[eCENT2].misc3 = 1;
13926 9 }
13927
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13928 {
13929 114 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13930 114 }
13931
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(Header->zelda_version <= 0x210)
13932 {
13933 9 guysbuf[eGLEEOK1F].misc6 = 16;
13934 9 guysbuf[eGLEEOK2F].misc6 = 16;
13935 9 guysbuf[eGLEEOK3F].misc6 = 16;
13936 9 guysbuf[eGLEEOK4F].misc6 = 16;
13937
13938 9 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13939 9 guysbuf[eBATROBE].misc4 = 1;
13940 //guysbuf[eSUMMONER].misc4 = 1;
13941 9 guysbuf[eWWIZ].misc4 = 1;
13942 9 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13943 9 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13944 9 }
13945
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(Header->zelda_version == 0x190)
13946 {
13947 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13948 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13949 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13950 4 }
13951
13952 // The versions here may not be correct
13953 // zelda_version>=0x211 handled at guyversion<24
13954
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version <= 0x190)
13955 {
13956 4 guysbuf[eCENT1].misc3 = 0;
13957 4 guysbuf[eCENT2].misc3 = 0;
13958 4 guysbuf[eMOLDORM].misc2 = 0;
13959 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13960 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13961 4 }
13962
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 else if(Header->zelda_version <= 0x210)
13963 {
13964 5 guysbuf[eCENT1].misc3 = 1;
13965 5 guysbuf[eCENT2].misc3 = 1;
13966 5 guysbuf[eMOLDORM].misc2 = 0;
13967 5 }
13968
13969
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13970 {
13971 9 guysbuf[eKEESE1].misc16 = 120;
13972 9 guysbuf[eKEESE2].misc16 = 120;
13973 9 guysbuf[eKEESE3].misc16 = 120;
13974 9 guysbuf[eKEESETRIB].misc16 = 120;
13975 9 guysbuf[eKEESE1].misc17 = 16;
13976 9 guysbuf[eKEESE2].misc17 = 16;
13977 9 guysbuf[eKEESE3].misc17 = 16;
13978 9 guysbuf[eKEESETRIB].misc17 = 16;
13979
13980 9 guysbuf[ePEAHAT].misc16 = 80;
13981 9 guysbuf[ePEAHAT].misc17 = 16;
13982
13983 9 guysbuf[eGHINI2].misc16 = 120;
13984 9 guysbuf[eGHINI2].misc17 = 10;
13985
13986 9 }
13987
13988
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
114 if(guyversion<=2)
13989 {
13990 9 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
13991 }
13992
13993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(guyversion > 3)
13994 {
13995 guydata tempguy;
13996
13997
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 105 times.
53865 for(int32_t i=0; i<MAXGUYS; i++)
13998 {
13999
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53760 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
14000 {
14001 if(i >= OLDBETAMAXGUYS)
14002 {
14003 memset(&guysbuf[i], 0, sizeof(guydata));
14004 continue;
14005 }
14006 }
14007
14008 53760 memset(&tempguy, 0, sizeof(guydata));
14009
14010
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.flags),f,keepdata))
14011 {
14012 return qe_invalid;
14013 }
14014
14015
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.flags2),f,keepdata))
14016 {
14017 return qe_invalid;
14018 }
14019
14020
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion >= 36 ) //expanded tiles
14021 {
14022
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.tile),f,keepdata))
14023 {
14024 return qe_invalid;
14025 }
14026 14848 }
14027 else
14028 {
14029
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetw(&(tempguy.tile),f,keepdata))
14030 {
14031 return qe_invalid;
14032 }
14033 }
14034
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.width),f,keepdata))
14035 {
14036 return qe_invalid;
14037 }
14038
14039
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.height),f,keepdata))
14040 {
14041 return qe_invalid;
14042 }
14043
14044
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion >= 36 ) //expanded tiles
14045 {
14046
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
14047 {
14048 return qe_invalid;
14049 }
14050 14848 }
14051 else
14052 {
14053
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
14054 {
14055 return qe_invalid;
14056 }
14057 }
14058
14059
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.s_width),f,keepdata))
14060 {
14061 return qe_invalid;
14062 }
14063
14064
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.s_height),f,keepdata))
14065 {
14066 return qe_invalid;
14067 }
14068
14069
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion >= 36 ) //expanded tiles
14070 {
14071
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
14072 {
14073 return qe_invalid;
14074 }
14075 14848 }
14076 else
14077 {
14078
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
14079 {
14080 return qe_invalid;
14081 }
14082 }
14083
14084
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.e_width),f,keepdata))
14085 {
14086 return qe_invalid;
14087 }
14088
14089
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.e_height),f,keepdata))
14090 {
14091 return qe_invalid;
14092 }
14093
14094
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.hp),f,keepdata))
14095 {
14096 return qe_invalid;
14097 }
14098
14099
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.family),f,keepdata))
14100 {
14101 return qe_invalid;
14102 }
14103
14104
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
53760 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14105 {
14106 if(get_bit(quest_rules,qr_NEWENEMYTILES))
14107 {
14108 tempguy.s_tile=tempguy.e_tile+120;
14109 tempguy.s_width=tempguy.e_width;
14110 tempguy.s_height=tempguy.e_height;
14111 }
14112 else tempguy.s_tile=860;
14113 }
14114
14115
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.cset),f,keepdata))
14116 {
14117 return qe_invalid;
14118 }
14119
14120
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.anim),f,keepdata))
14121 {
14122 return qe_invalid;
14123 }
14124
14125
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
14126 {
14127 return qe_invalid;
14128 }
14129
14130
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.frate),f,keepdata))
14131 {
14132 return qe_invalid;
14133 }
14134
14135
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
14136 {
14137 return qe_invalid;
14138 }
14139
14140
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 13) // April 2009
14141 {
14142 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14143 {
14144 tempguy.frate *= 2;
14145 tempguy.e_frate *= 2;
14146 }
14147 }
14148
14149
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 14) // May 1 2009
14150 {
14151 if(tempguy.anim==a2FRMSLOW)
14152 {
14153 tempguy.anim=a2FRM;
14154 tempguy.frate *= 2;
14155 }
14156
14157 if(tempguy.e_anim==a2FRMSLOW)
14158 {
14159 tempguy.e_anim=a2FRM;
14160 tempguy.e_frate *= 2;
14161 }
14162
14163 if(tempguy.anim==aFLIPSLOW)
14164 {
14165 tempguy.anim=aFLIP;
14166 tempguy.frate *= 2;
14167 }
14168
14169 if(tempguy.e_anim==aFLIPSLOW)
14170 {
14171 tempguy.e_anim=aFLIP;
14172 tempguy.e_frate *= 2;
14173 }
14174
14175 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14176
14177 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14178
14179 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14180 {
14181 tempguy.anim=a4FRM4DIR;
14182 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14183 }
14184
14185 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14186 {
14187 tempguy.e_anim=a4FRM4DIR;
14188 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14189 }
14190 }
14191
14192
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.dp),f,keepdata))
14193 {
14194 return qe_invalid;
14195 }
14196
14197 //correction for guy fire
14198
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 6)
14199 {
14200 if(i == gFIRE)
14201 tempguy.dp = 2;
14202 }
14203
14204
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14205 {
14206 return qe_invalid;
14207 }
14208
14209
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14210 {
14211 return qe_invalid;
14212 }
14213
14214 //correction for bosses using triple, "rising" fireballs
14215
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 5)
14216 {
14217 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14218 i == eGOHMA3 || i == eGOHMA4)
14219 {
14220 if(tempguy.weapon == ewFireball)
14221 tempguy.weapon = ewFireball2;
14222 }
14223 }
14224
14225
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.rate),f,keepdata))
14226 {
14227 return qe_invalid;
14228 }
14229
14230
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14231 {
14232 return qe_invalid;
14233 }
14234
14235
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.step),f,keepdata))
14236 {
14237 return qe_invalid;
14238 }
14239
14240 // HIGHLY UNORTHODOX UPDATING THING, part 2
14241
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 52224 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
53760 if(fixpolsvoice && tempguy.family==eePOLSV)
14242 {
14243 tempguy.step /= 2;
14244 }
14245
14246
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.homing),f,keepdata))
14247 {
14248 return qe_invalid;
14249 }
14250
14251
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14252 {
14253 return qe_invalid;
14254 }
14255
14256
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14257 {
14258 return qe_invalid;
14259 }
14260
14261
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14262 {
14263
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14264 {
14265 return qe_invalid;
14266 }
14267
14268
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14269 {
14270 return qe_invalid;
14271 }
14272
14273
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14274 {
14275 return qe_invalid;
14276 }
14277
14278
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14279 {
14280 return qe_invalid;
14281 }
14282
14283
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14284 {
14285 return qe_invalid;
14286 }
14287
14288
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14289 {
14290 return qe_invalid;
14291 }
14292
14293
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14294 {
14295 return qe_invalid;
14296 }
14297
14298
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14299 {
14300 return qe_invalid;
14301 }
14302
14303
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14304 {
14305 return qe_invalid;
14306 }
14307
14308
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14309 {
14310 return qe_invalid;
14311 }
14312 53760 }
14313 else
14314 {
14315 int16_t tempMisc;
14316
14317 if(!p_igetw(&tempMisc,f,keepdata))
14318 {
14319 return qe_invalid;
14320 }
14321
14322 tempguy.misc1=tempMisc;
14323
14324 if(!p_igetw(&tempMisc,f,keepdata))
14325 {
14326 return qe_invalid;
14327 }
14328
14329 tempguy.misc2=tempMisc;
14330
14331 if(!p_igetw(&tempMisc,f,keepdata))
14332 {
14333 return qe_invalid;
14334 }
14335
14336 tempguy.misc3=tempMisc;
14337
14338 if(!p_igetw(&tempMisc,f,keepdata))
14339 {
14340 return qe_invalid;
14341 }
14342
14343 tempguy.misc4=tempMisc;
14344
14345 if(!p_igetw(&tempMisc,f,keepdata))
14346 {
14347 return qe_invalid;
14348 }
14349
14350 tempguy.misc5=tempMisc;
14351
14352 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14353 {
14354 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14355 tempguy.misc5 = 74;
14356 }
14357
14358 if(!p_igetw(&tempMisc,f,keepdata))
14359 {
14360 return qe_invalid;
14361 }
14362
14363 tempguy.misc6=tempMisc;
14364
14365 if(!p_igetw(&tempMisc,f,keepdata))
14366 {
14367 return qe_invalid;
14368 }
14369
14370 tempguy.misc7=tempMisc;
14371
14372 if(!p_igetw(&tempMisc,f,keepdata))
14373 {
14374 return qe_invalid;
14375 }
14376
14377 tempguy.misc8=tempMisc;
14378
14379 if(!p_igetw(&tempMisc,f,keepdata))
14380 {
14381 return qe_invalid;
14382 }
14383
14384 tempguy.misc9=tempMisc;
14385
14386 if(!p_igetw(&tempMisc,f,keepdata))
14387 {
14388 return qe_invalid;
14389 }
14390
14391 tempguy.misc10=tempMisc;
14392 }
14393
14394
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14395 {
14396 return qe_invalid;
14397 }
14398
14399
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14400 {
14401 return qe_invalid;
14402 }
14403
14404
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetw(&(tempguy.extend),f,keepdata))
14405 {
14406 return qe_invalid;
14407 }
14408
14409 //! Enemy Defences
14410
14411 //If a 2.50 quest, use only the 2.5 defences.
14412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14413 {
14414
2/2
✓ Branch 0 taken 1021440 times.
✓ Branch 1 taken 53760 times.
1075200 for(int32_t j=0; j<edefLAST; j++)
14415 {
14416
1/2
✓ Branch 0 taken 1021440 times.
✗ Branch 1 not taken.
1021440 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14417 {
14418 return qe_invalid;
14419 }
14420 1021440 }
14421 //then copy the generic script defence to all the new script defences
14422
14423 53760 }
14424
14425
14426
14427
14428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(guyversion >= 18)
14429 {
14430
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14431 {
14432 return qe_invalid;
14433 }
14434
14435
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14436 {
14437 return qe_invalid;
14438 }
14439 53760 }
14440
14441
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion >= 22)
14442 {
14443
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14444 {
14445 return qe_invalid;
14446 }
14447
14448
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14449 {
14450 return qe_invalid;
14451 }
14452 53760 }
14453 else if(guyversion >= 19)
14454 {
14455 int16_t tempMisc;
14456
14457 if(!p_igetw(&tempMisc,f,keepdata))
14458 {
14459 return qe_invalid;
14460 }
14461
14462 tempguy.misc11=tempMisc;
14463
14464 if(!p_igetw(&tempMisc,f,keepdata))
14465 {
14466 return qe_invalid;
14467 }
14468
14469 tempguy.misc12=tempMisc;
14470 }
14471
14472 //If a 2.54 or later quest, use all of the defences.
14473
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion > 24) // Add new guyversion conditional statement
14474 {
14475
2/2
✓ Branch 0 taken 326656 times.
✓ Branch 1 taken 14848 times.
341504 for(int32_t j=edefLAST; j<edefLAST255; j++)
14476 {
14477
1/2
✓ Branch 0 taken 326656 times.
✗ Branch 1 not taken.
326656 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14478 {
14479 return qe_invalid;
14480 }
14481 326656 }
14482 14848 }
14483
14484
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14485 {
14486
2/2
✓ Branch 0 taken 389120 times.
✓ Branch 1 taken 38912 times.
428032 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14487 {
14488 389120 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14489 389120 }
14490 38912 }
14491
14492 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14493
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion > 25)
14494 {
14495
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14496 {
14497 return qe_invalid;
14498 }
14499
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14500 {
14501 return qe_invalid;
14502 }
14503
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14504 {
14505 return qe_invalid;
14506 }
14507
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14508 {
14509 return qe_invalid;
14510 }
14511
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14512 {
14513 return qe_invalid;
14514 }
14515 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14516
14517 */
14518 14848 }
14519 //More Enemy Editor vars for 2.60
14520
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion > 26)
14521 {
14522
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14523 {
14524 return qe_invalid;
14525 }
14526
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14527 {
14528 return qe_invalid;
14529 }
14530
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14531 {
14532 return qe_invalid;
14533 }
14534
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14535 {
14536 return qe_invalid;
14537 }
14538
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14539 {
14540 return qe_invalid;
14541 }
14542 14848 }
14543
14544
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14545 {
14546 38912 tempguy.wpnsprite = 0;
14547 38912 }
14548
14549
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion > 27)
14550 {
14551
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14552 {
14553 return qe_invalid;
14554 }
14555 14848 }
14556
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14557 {
14558 38912 tempguy.SIZEflags = 0;
14559 38912 }
14560
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion > 28)
14561 {
14562
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14563 {
14564 return qe_invalid;
14565 }
14566
14567 14848 }
14568
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14569 {
14570 38912 tempguy.frozentile = 0;
14571 38912 tempguy.frozencset = 0;
14572 38912 tempguy.frozenclock = 0;
14573
2/2
✓ Branch 0 taken 389120 times.
✓ Branch 1 taken 38912 times.
428032 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14574 38912 }
14575
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion >= 30)
14576 {
14577
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14578 {
14579 return qe_invalid;
14580 }
14581
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14582 {
14583 return qe_invalid;
14584 }
14585
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14586 {
14587 return qe_invalid;
14588 }
14589
2/2
✓ Branch 0 taken 148480 times.
✓ Branch 1 taken 14848 times.
163328 for ( int32_t q = 0; q < 10; q++ ) {
14590
1/2
✓ Branch 0 taken 148480 times.
✗ Branch 1 not taken.
148480 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14591 {
14592 return qe_invalid;
14593 }
14594 148480 }
14595
14596 14848 }
14597
14598
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion >= 34)
14599 {
14600
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14601 {
14602 return qe_invalid;
14603 }
14604
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14605 {
14606 return qe_invalid;
14607 }
14608
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14609 {
14610 return qe_invalid;
14611 }
14612
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14613 {
14614 return qe_invalid;
14615 }
14616
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14617 {
14618 return qe_invalid;
14619 }
14620
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14621 {
14622 return qe_invalid;
14623 }
14624
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14625 {
14626 return qe_invalid;
14627 }
14628
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14629 {
14630 return qe_invalid;
14631 }
14632
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14633 {
14634 return qe_invalid;
14635 }
14636
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14637 {
14638 return qe_invalid;
14639 }
14640
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14641 {
14642 return qe_invalid;
14643 }
14644
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14645 {
14646 return qe_invalid;
14647 }
14648
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14649 {
14650 return qe_invalid;
14651 }
14652
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14653 {
14654 return qe_invalid;
14655 }
14656
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14657 {
14658 return qe_invalid;
14659 }
14660
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14661 {
14662 return qe_invalid;
14663 }
14664
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14665 {
14666 return qe_invalid;
14667 }
14668
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14669 {
14670 return qe_invalid;
14671 }
14672
14673
2/2
✓ Branch 0 taken 475136 times.
✓ Branch 1 taken 14848 times.
489984 for ( int32_t q = 0; q < 32; q++ ) {
14674
1/2
✓ Branch 0 taken 475136 times.
✗ Branch 1 not taken.
475136 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14675 {
14676 return qe_invalid;
14677 }
14678 475136 }
14679
2/2
✓ Branch 0 taken 475136 times.
✓ Branch 1 taken 14848 times.
489984 for ( int32_t q = 0; q < 32; q++ ) {
14680
1/2
✓ Branch 0 taken 475136 times.
✗ Branch 1 not taken.
475136 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14681 {
14682 return qe_invalid;
14683 }
14684 475136 }
14685
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&(tempguy.script),f,keepdata))
14686 {
14687 return qe_invalid;
14688 }
14689 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14690
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; q++ )
14691 {
14692
1/2
✓ Branch 0 taken 118784 times.
✗ Branch 1 not taken.
118784 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14693 {
14694 return qe_invalid;
14695 }
14696 118784 }
14697
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 14848 times.
44544 for ( int32_t q = 0; q < 2; q++ )
14698 {
14699
1/2
✓ Branch 0 taken 29696 times.
✗ Branch 1 not taken.
29696 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14700 {
14701 return qe_invalid;
14702 }
14703 29696 }
14704
14705 14848 }
14706
14707
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion >= 37)
14708 {
14709
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14710 {
14711 return qe_invalid;
14712 }
14713 14848 }
14714
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14715
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if(guyversion >= 38)
14716 {
14717
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14718 {
14719 return qe_invalid;
14720 }
14721
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14722 {
14723 return qe_invalid;
14724 }
14725
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14726 {
14727 return qe_invalid;
14728 }
14729
14730 14848 }
14731
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion < 38 )
14732 {
14733 38912 tempguy.misc13 = 0;
14734 38912 tempguy.misc14 = 0;
14735 38912 tempguy.misc15 = 0;
14736 38912 }
14737
14738
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if ( guyversion >= 39 )
14739 {
14740
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; q++ )
14741 {
14742
2/2
✓ Branch 0 taken 7720960 times.
✓ Branch 1 taken 118784 times.
7839744 for ( int32_t w = 0; w < 65; w++ )
14743 {
14744
1/2
✓ Branch 0 taken 7720960 times.
✗ Branch 1 not taken.
7720960 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14745 {
14746 return qe_invalid;
14747 }
14748 7720960 }
14749
2/2
✓ Branch 0 taken 7720960 times.
✓ Branch 1 taken 118784 times.
7839744 for ( int32_t w = 0; w < 65; w++ )
14750 {
14751
1/2
✓ Branch 0 taken 7720960 times.
✗ Branch 1 not taken.
7720960 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14752 {
14753 return qe_invalid;
14754 }
14755 7720960 }
14756 118784 }
14757
14758
14759 14848 }
14760
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion < 39 ) //apply old InitD strings to both
14761 {
14762
2/2
✓ Branch 0 taken 311296 times.
✓ Branch 1 taken 38912 times.
350208 for ( int32_t q = 0; q < 8; q++ )
14763 {
14764 311296 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14765 311296 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14766 311296 }
14767 38912 }
14768
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if ( guyversion >= 40 )
14769 {
14770
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14771 {
14772 return qe_invalid;
14773 }
14774 14848 }
14775
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if ( guyversion < 40 )
14776 {
14777 38912 tempguy.weaponscript = 0;
14778 38912 }
14779 //eweapon script InitD
14780
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
53760 if ( guyversion >= 41 )
14781 {
14782
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for ( int32_t q = 0; q < 8; q++ )
14783 {
14784
1/2
✓ Branch 0 taken 118784 times.
✗ Branch 1 not taken.
118784 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14785 {
14786 return qe_invalid;
14787 }
14788 118784 }
14789
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if ( guy_cversion < 4 )
14790 {
14791 if ( tempguy.family == eeKEESE )
14792 {
14793
14794 if ( !tempguy.misc1 )
14795 {
14796 tempguy.misc16 = 120;
14797 tempguy.misc17 = 16;
14798
14799 }
14800 }
14801 if ( tempguy.family == eePEAHAT )
14802 {
14803 tempguy.misc16 = 80;
14804 tempguy.misc17 = 16;
14805 }
14806
14807 if ( tempguy.family == eeGHINI )
14808 {
14809 tempguy.misc16 = 120;
14810 tempguy.misc17 = 10;
14811 }
14812
14813 }
14814 14848 }
14815
14816
14817
14818 //default weapon sprites (quest version < 2.54)
14819 //port over old defaults -Z
14820
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion < 32)
14821 {
14822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38912 times.
38912 if ( tempguy.wpnsprite <= 0 )
14823 {
14824
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32390 times.
✓ Branch 4 taken 299 times.
✓ Branch 5 taken 311 times.
✓ Branch 6 taken 924 times.
✓ Branch 7 taken 488 times.
✓ Branch 8 taken 904 times.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 135 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 359 times.
✓ Branch 14 taken 751 times.
✓ Branch 15 taken 105 times.
✓ Branch 16 taken 79 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 759 times.
38912 switch(tempguy.weapon)
14825 {
14826 case wNone:
14827 32390 tempguy.wpnsprite = 0; break;
14828
14829 case wSword:
14830 case wBeam:
14831 case wBrang:
14832 case wBomb:
14833 case wSBomb:
14834 case wLitBomb:
14835 case wLitSBomb:
14836 case wArrow:
14837 case wFire:
14838 case wWhistle:
14839 case wBait:
14840 case wWand:
14841 case wMagic:
14842 case wCatching:
14843 case wWind:
14844 case wRefMagic:
14845 case wRefFireball:
14846 case wRefRock:
14847 case wHammer:
14848 case wHookshot:
14849 case wHSHandle:
14850 case wHSChain:
14851 case wSSparkle:
14852 case wFSparkle:
14853 case wSmack:
14854 case wPhantom:
14855 case wCByrna:
14856 case wRefBeam:
14857 case wStomp:
14858 case lwMax:
14859 case wScript1:
14860 case wScript2:
14861 case wScript3:
14862 case wScript4:
14863 case wScript5:
14864 case wScript6:
14865 case wScript7:
14866 case wScript8:
14867 case wScript9:
14868 case wScript10:
14869 case wIce:
14870 //Cannot use any of these weapons yet.
14871 tempguy.wpnsprite = -1;
14872 break;
14873
14874 case wEnemyWeapons:
14875 1292 case ewFireball: tempguy.wpnsprite = 17; break;
14876
14877 299 case ewArrow: tempguy.wpnsprite = 19; break;
14878 311 case ewBrang: tempguy.wpnsprite = 4; break;
14879 924 case ewSword: tempguy.wpnsprite = 20; break;
14880 488 case ewRock: tempguy.wpnsprite = 18; break;
14881 904 case ewMagic: tempguy.wpnsprite = 21; break;
14882 79 case ewBomb: tempguy.wpnsprite = 78; break;
14883 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14884 135 case ewLitBomb: tempguy.wpnsprite = 76; break;
14885 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14886 359 case ewFireTrail: tempguy.wpnsprite = 80; break;
14887 751 case ewFlame: tempguy.wpnsprite = 35; break;
14888 105 case ewWind: tempguy.wpnsprite = 36; break;
14889 79 case ewFlame2: tempguy.wpnsprite = 81; break;
14890 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14891 case ewIce: tempguy.wpnsprite = 83; break;
14892 759 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14893
14894
14895 default: break; //No assign.
14896 }
14897 38912 }
14898 38912 }
14899
14900 //default weapon fire sound (quest version < 2.54)
14901 //port over old defaults and zero new data. -Z
14902
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion < 34)
14903 {
14904
2/2
✓ Branch 0 taken 1245184 times.
✓ Branch 1 taken 38912 times.
1284096 for ( int32_t q = 0; q < 32; q++ )
14905 {
14906 1245184 tempguy.movement[q] = 0;
14907 1245184 tempguy.new_weapon[q] = 0;
14908
14909 1245184 }
14910
14911 //NPC Script attributes.
14912 38912 tempguy.script = 0; //No scripted enemies existed. -Z
14913
2/2
✓ Branch 0 taken 311296 times.
✓ Branch 1 taken 38912 times.
350208 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14914
2/2
✓ Branch 0 taken 77824 times.
✓ Branch 1 taken 38912 times.
116736 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14915
14916 38912 tempguy.misc16 = 0;
14917 38912 tempguy.misc17 = 0;
14918 38912 tempguy.misc18 = 0;
14919 38912 tempguy.misc19 = 0;
14920 38912 tempguy.misc20 = 0;
14921 38912 tempguy.misc21 = 0;
14922 38912 tempguy.misc22 = 0;
14923 38912 tempguy.misc23 = 0;
14924 38912 tempguy.misc24 = 0;
14925 38912 tempguy.misc25 = 0;
14926 38912 tempguy.misc26 = 0;
14927 38912 tempguy.misc27 = 0;
14928 38912 tempguy.misc28 = 0;
14929 38912 tempguy.misc29 = 0;
14930 38912 tempguy.misc30 = 0;
14931 38912 tempguy.misc31 = 0;
14932 38912 tempguy.misc32 = 0;
14933
14934 //old default sounds
14935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38912 times.
38912 if ( tempguy.firesfx <= 0 )
14936 {
14937
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32390 times.
✓ Branch 4 taken 299 times.
✓ Branch 5 taken 311 times.
✓ Branch 6 taken 924 times.
✓ Branch 7 taken 488 times.
✓ Branch 8 taken 904 times.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 135 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 359 times.
✓ Branch 14 taken 751 times.
✓ Branch 15 taken 105 times.
✓ Branch 16 taken 79 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 759 times.
38912 switch(tempguy.weapon)
14938 {
14939 case wNone:
14940 32390 tempguy.firesfx = 0; break;
14941
14942 case wSword:
14943 case wBeam:
14944 case wBrang:
14945 case wBomb:
14946 case wSBomb:
14947 case wLitBomb:
14948 case wLitSBomb:
14949 case wArrow:
14950 case wFire:
14951 case wWhistle:
14952 case wBait:
14953 case wWand:
14954 case wMagic:
14955 case wCatching:
14956 case wWind:
14957 case wRefMagic:
14958 case wRefFireball:
14959 case wRefRock:
14960 case wHammer:
14961 case wHookshot:
14962 case wHSHandle:
14963 case wHSChain:
14964 case wSSparkle:
14965 case wFSparkle:
14966 case wSmack:
14967 case wPhantom:
14968 case wCByrna:
14969 case wRefBeam:
14970 case wStomp:
14971 case lwMax:
14972 case wScript1:
14973 case wScript2:
14974 case wScript3:
14975 case wScript4:
14976 case wScript5:
14977 case wScript6:
14978 case wScript7:
14979 case wScript8:
14980 case wScript9:
14981 case wScript10:
14982 case wIce:
14983 //Cannot use any of these weapons yet.
14984 tempguy.firesfx = -1;
14985 break;
14986
14987 case wEnemyWeapons:
14988 1292 case ewFireball: tempguy.firesfx = 40; break;
14989
14990 299 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14991 311 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14992 924 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14993 488 case ewRock: tempguy.firesfx = 51; break;
14994 904 case ewMagic: tempguy.firesfx = 32; break;
14995 79 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14996 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14997 135 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14998 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14999 359 case ewFireTrail: tempguy.firesfx = 13; break;
15000 751 case ewFlame: tempguy.firesfx = 13; break;
15001 105 case ewWind: tempguy.firesfx = 32; break;
15002 79 case ewFlame2: tempguy.firesfx = 13; break;
15003 case ewFlame2Trail: tempguy.firesfx = 13; break;
15004 case ewIce: tempguy.firesfx = 44; break;
15005 759 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
15006
15007 //what about special attacks (e.g. summoning == 56)
15008 default: break; //No assign.
15009 }
15010 38912 }
15011 38912 }
15012
15013 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
15014
4/6
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14848 times.
53760 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
15015 {
15016
2/2
✓ Branch 0 taken 3527 times.
✓ Branch 1 taken 35385 times.
38912 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
15017 38912 }
15018 //Keese and bat halt rates.
15019
3/4
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 14848 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38912 times.
53760 if ( guyversion < 42 && guy_cversion < 4 )
15020 {
15021
15022
2/2
✓ Branch 0 taken 38388 times.
✓ Branch 1 taken 524 times.
38912 if ( tempguy.family == eeKEESE )
15023 {
15024
15025
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 322 times.
524 if ( !tempguy.misc1 )
15026 {
15027 322 tempguy.misc16 = 120;
15028 322 tempguy.misc17 = 16;
15029
15030 322 }
15031 524 }
15032
2/2
✓ Branch 0 taken 38747 times.
✓ Branch 1 taken 165 times.
38912 if ( tempguy.family == eePEAHAT )
15033 {
15034 165 tempguy.misc16 = 80;
15035 165 tempguy.misc17 = 16;
15036 165 }
15037
2/2
✓ Branch 0 taken 38836 times.
✓ Branch 1 taken 76 times.
38912 if ( tempguy.family == eeGHINI )
15038 {
15039 76 tempguy.misc16 = 120;
15040 76 tempguy.misc17 = 10;
15041 76 }
15042
15043
15044 38912 }
15045
15046
15047 //miscellaneous other corrections
15048 //fix the mirror wizzrobe -DD
15049
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 7)
15050 {
15051 if(i == eMWIZ)
15052 {
15053 tempguy.misc2 = 0;
15054 tempguy.misc4 = 1;
15055 }
15056 }
15057
15058
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 8)
15059 {
15060 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
15061 {
15062 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
15063 tempguy.misc5 = 4; //neck length in segments
15064 tempguy.misc6 = 8; //neck offset from first body tile
15065 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
15066 tempguy.misc8 = 168; //head offset from first body tile
15067 tempguy.misc9 = 228; //flying head offset from first body tile
15068
15069 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
15070 {
15071 tempguy.misc6 += 10; //neck offset from first body tile
15072 tempguy.misc8 -= 12; //head offset from first body tile
15073 }
15074 }
15075 }
15076
15077
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 10) // December 2007 - Dodongo CSet fix
15078 {
15079 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
15080 tempguy.bosspal = spDIG;
15081 }
15082
15083
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 11) // December 2007 - Spinning Tile fix
15084 {
15085 if(tempguy.family==eeSPINTILE)
15086 {
15087 tempguy.flags |= guy_superman;
15088 tempguy.item_set = 0; // Don't drop items
15089 tempguy.step = 300;
15090 }
15091 }
15092
15093
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
15094 {
15095 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
15096 {
15097 if(tempguy.family==eeROPE)
15098 {
15099 tempguy.flags2 &= ~guy_flashing;
15100 }
15101 }
15102
15103 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
15104 {
15105 if(tempguy.family==eeBUBBLE)
15106 {
15107 tempguy.flags2 &= ~guy_flashing;
15108 }
15109 }
15110
15111 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
15112 {
15113 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
15114 {
15115 tempguy.flags2 |= guy_blinking;
15116 }
15117
15118 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
15119 {
15120 tempguy.flags2 |= guy_transparent;
15121 }
15122 }
15123 }
15124
15125
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
15126 {
15127 if(i==gFIRE)
15128 {
15129 tempguy.e_anim = aFLIP;
15130 tempguy.e_frate = 24;
15131 }
15132
15133 if(i==gFAIRY)
15134 {
15135 tempguy.e_anim = a2FRM;
15136 tempguy.e_frate = 16;
15137 }
15138 }
15139
15140
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
15141 {
15142 if(i==0) Z_message("Updating guys to version 16...\n");
15143
15144 update_guy_1(&tempguy);
15145
15146 if(i==eMPOLSV)
15147 {
15148 tempguy.defense[edefARROW] = edCHINK;
15149 tempguy.defense[edefMAGIC] = ed1HKO;
15150 tempguy.defense[edefREFMAGIC] = ed1HKO;
15151 }
15152 }
15153
15154
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 17) // December 2009
15155 {
15156 if(tempguy.family==eePROJECTILE)
15157 {
15158 tempguy.misc1 = 0;
15159 }
15160 }
15161
15162
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 18) // January 2010
15163 {
15164 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15165 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15166
15167 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15168 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15169
15170 if(tempguy.family == eeAQUA)
15171 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15172 else if(tempguy.family == eeMANHAN)
15173 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15174 else if(tempguy.family==eePATRA)
15175 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15176 else if(tempguy.family==eeGHOMA)
15177 {
15178 for(int32_t j=0; j<edefLAST; j++)
15179 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15180
15181 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15182
15183 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15184
15185 tempguy.misc1--;
15186 }
15187 else if(tempguy.family == eeGLEEOK)
15188 {
15189 for(int32_t j=0; j<edefLAST; j++)
15190 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15191
15192 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15193 }
15194 else if(tempguy.family == eeARMOS)
15195 {
15196 tempguy.family=eeWALK;
15197 tempguy.hrate = 0;
15198 tempguy.misc10 = tempguy.misc1;
15199 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15200 tempguy.misc9 = e9tARMOS;
15201 }
15202 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15203 {
15204 tempguy.family=eeWALK;
15205 tempguy.hrate = 0;
15206 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15207 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15208 }
15209
15210 // Spawn animation flags
15211 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15212 tempguy.flags |= guy_fadeflicker;
15213 else
15214 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15215 }
15216
15217
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 20) // April 2010
15218 {
15219 if(tempguy.family == eeTRAP)
15220 {
15221 tempguy.misc2 = tempguy.misc10;
15222
15223 if(tempguy.misc10>=1)
15224 {
15225 tempguy.misc1++;
15226 }
15227
15228 tempguy.misc10 = 0;
15229 }
15230
15231 // Bomb Blast fix
15232 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15233 tempguy.weapon = ewLitBomb;
15234 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15235 tempguy.weapon = ewLitSBomb;
15236 }
15237
15238
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 21) // September 2011
15239 {
15240 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15241 {
15242 if(tempguy.family == eeKEESETRIB)
15243 {
15244 tempguy.family = eeKEESE;
15245 tempguy.misc2 = e2tKEESETRIB;
15246 tempguy.misc1 = 0;
15247 }
15248
15249 tempguy.rate = 2;
15250 tempguy.hrate = 8;
15251 tempguy.homing = 0;
15252 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15253 }
15254 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15255 {
15256 if(tempguy.family == eePEAHAT)
15257 {
15258 tempguy.rate = 4;
15259 tempguy.step = 62;
15260 }
15261 else
15262 tempguy.step = 25;
15263
15264 tempguy.hrate = 8;
15265 tempguy.homing = 0;
15266 }
15267 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15268 {
15269 if(tempguy.family == eeMANHAN)
15270 tempguy.step=50;
15271
15272 tempguy.hrate = 16;
15273 tempguy.homing = 0;
15274 }
15275 else if(tempguy.family == eeGLEEOK)
15276 {
15277 tempguy.rate = 2;
15278 tempguy.homing = 0;
15279 tempguy.hrate = 9;
15280 tempguy.step=89;
15281 }
15282 else if(tempguy.family == eeGHINI)
15283 {
15284 tempguy.rate = 4;
15285 tempguy.hrate = 12;
15286 tempguy.step=62;
15287 tempguy.homing = 0;
15288 }
15289
15290 // Bigdig random rate fix
15291 if(tempguy.family==eeDIG && tempguy.misc10==1)
15292 {
15293 tempguy.rate = 2;
15294 }
15295 }
15296
15297
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if(guyversion < 24) // November 2012
15298 {
15299 if(tempguy.family==eeLANM)
15300 tempguy.misc3 = 1;
15301 else if(tempguy.family==eeMOLD)
15302 tempguy.misc2 = 0;
15303 }
15304
15305
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15306 {
15307
2/2
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 38258 times.
38912 if(tempguy.family!=eeDIG)
15308 {
15309 38258 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15310 38258 }
15311
15312 38912 }
15313 // does not seem to solve the issue!
15314
1/2
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
53760 if ( Header->zelda_version <= 0x210 )
15315 {
15316 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15317 if ( tempguy.family == eeDONGO )
15318 {
15319 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15320 }
15321 }
15322
15323
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion >= 42)
15324 {
15325
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 1024 times.
14848 if(guyversion >= 47)
15326 {
15327
1/2
✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
13824 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15328 {
15329 return qe_invalid;
15330 }
15331 13824 }
15332 else
15333 {
15334 byte fl;
15335
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f,keepdata))
15336 {
15337 return qe_invalid;
15338 }
15339 1024 tempguy.moveflags = fl;
15340 }
15341 14848 }
15342 else
15343 {
15344
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30458 times.
✓ Branch 2 taken 1192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 515 times.
✓ Branch 5 taken 275 times.
✓ Branch 6 taken 239 times.
✓ Branch 7 taken 5787 times.
38912 switch(tempguy.family)
15345 {
15346 //No gravity; floats over pits
15347 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15348 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15349 //Special (bosses, etc)
15350 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15351 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15352 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15353 30458 tempguy.moveflags = FLAG_CAN_PITWALK;
15354 30458 break;
15355 //No gravity, but falls in pits
15356 case eeLEV:
15357 515 tempguy.moveflags = FLAG_CAN_PITFALL;
15358 515 break;
15359 //Bosses that respect pits
15360 case eeDONGO:
15361 275 tempguy.moveflags = FLAG_OBEYS_GRAV;
15362 275 break;
15363 case eeLANM:
15364 239 tempguy.moveflags = 0;
15365 239 break;
15366 //Gravity, floats over pits
15367 case eeWIZZ: case eeWALLM: case eeGHINI:
15368 1192 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15369 1192 break;
15370 //Gravity and falls in pits
15371 case eeWALK:
15372
4/4
✓ Branch 0 taken 5469 times.
✓ Branch 1 taken 318 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 5191 times.
5787 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15373 596 break;
15374 [[fallthrough]];
15375 case eeOTHER:
15376 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15377 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15378 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15379 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15380 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15381 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15382 5637 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15383 5637 }
15384 }
15385
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion < 43)
15386 {
15387
2/2
✓ Branch 0 taken 31650 times.
✓ Branch 1 taken 7262 times.
38912 switch(tempguy.family)
15388 {
15389 //No gravity; floats over pits
15390 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15391 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15392 //Special (bosses, etc)
15393 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15394 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15395 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15396 case eeWIZZ: case eeWALLM: case eeGHINI:
15397 //Gravity, floats over pits
15398 31650 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15399 31650 break;
15400 }
15401 38912 }
15402
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if (guyversion < 44)
15403 {
15404
2/2
✓ Branch 0 taken 38546 times.
✓ Branch 1 taken 366 times.
38912 if ( tempguy.family == eeGHOMA )
15405 {
15406 366 tempguy.flags |= guy_fadeinstant;
15407 366 }
15408 38912 }
15409
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if (guyversion > 44)
15410 {
15411
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15412 {
15413 return qe_invalid;
15414 }
15415
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15416 {
15417 return qe_invalid;
15418 }
15419
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15420 {
15421 return qe_invalid;
15422 }
15423 14848 }
15424 else
15425 {
15426
2/2
✓ Branch 0 taken 38761 times.
✓ Branch 1 taken 151 times.
38912 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15427 38912 tempguy.spr_death = iwDeath;
15428 38912 tempguy.spr_spawn = iwSpawn;
15429 }
15430
15431
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 38912 times.
53760 if(guyversion < 46)
15432 {
15433
4/4
✓ Branch 0 taken 5787 times.
✓ Branch 1 taken 33125 times.
✓ Branch 2 taken 5469 times.
✓ Branch 3 taken 318 times.
38912 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15434 {
15435 318 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15436 318 }
15437 38912 }
15438
15439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53760 times.
53760 if(keepdata)
15440 {
15441 53760 guysbuf[i] = tempguy;
15442 53760 }
15443 53760 }
15444 105 }
15445
15446 105 return 0;
15447 114 }
15448
15449 void update_guy_1(guydata *tempguy) // November 2009
15450 {
15451 bool doesntcount = false;
15452 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15453
15454 switch(tempguy->family)
15455 {
15456 case 1: //eeWALK
15457 switch(tempguy->misc10)
15458 {
15459 case 0: //Stalfos
15460 if(tempguy->misc1==1) // Fires four projectiles at once
15461 tempguy->misc1=4;
15462
15463 break;
15464
15465 case 1: //Darknut
15466 goto darknuts;
15467 break;
15468 }
15469
15470 tempguy->misc10 = 0;
15471 break;
15472
15473 case 2: //eeSHOOT
15474 tempguy->family = eeWALK;
15475
15476 switch(tempguy->misc10)
15477 {
15478 case 0: //Octorok
15479 if(tempguy->misc1==1||tempguy->misc1==2)
15480 {
15481 tempguy->misc1=e1tFIREOCTO;
15482 tempguy->misc2=e2tFIREOCTO;
15483 }
15484 else tempguy->misc1 = 0;
15485
15486 tempguy->misc6=tempguy->misc4;
15487 tempguy->misc4=tempguy->misc3;
15488 tempguy->misc3=0;
15489 break;
15490
15491 case 1: // Moblin
15492 tempguy->misc1 = 0;
15493 break;
15494
15495 case 2: //Lynel
15496 tempguy->misc6=tempguy->misc1+1;
15497 tempguy->misc1=0;
15498 break;
15499
15500 case 3: //Stalfos 2
15501 if(tempguy->misc1==1) // Fires four projectiles at once
15502 tempguy->misc1=e1t4SHOTS;
15503 else tempguy->misc1 = 0;
15504
15505 break;
15506
15507 case 4: //Darknut 5
15508 darknuts:
15509 tempguy->defense[edefFIRE] = edIGNORE;
15510 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15511 tempguy->defense[edefHOOKSHOT] = 0;
15512 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15513 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15514
15515 if(tempguy->misc1==1)
15516 tempguy->misc1=2;
15517 else if(tempguy->misc1==2)
15518 {
15519 tempguy->misc4=tempguy->misc3;
15520 tempguy->misc3=tempguy->misc2;
15521 tempguy->misc2=e2tSPLIT;
15522 tempguy->misc1 = 0;
15523 }
15524 else tempguy->misc1 = 0;
15525
15526 tempguy->flags |= inv_front;
15527
15528 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15529 tempguy->flags |= guy_bkshield;
15530
15531 break;
15532 }
15533
15534 tempguy->misc10 = 0;
15535 break;
15536
15537 /*
15538 case 9: //eeARMOS
15539 tempguy->family = eeWALK;
15540 break;
15541 */
15542 case 11: //eeGEL
15543 case 33: //eeGELTRIB
15544 if(tempguy->family==33)
15545 {
15546 tempguy->misc4 = 1;
15547
15548 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15549 tempguy->misc3 = tempguy->misc2;
15550
15551 tempguy->misc2 = e2tTRIBBLE;
15552 }
15553 else
15554 {
15555 tempguy->misc4 = 0;
15556 tempguy->misc3 = 0;
15557 tempguy->misc2 = 0;
15558 }
15559
15560 tempguy->family = eeWALK;
15561
15562 if(tempguy->misc1)
15563 {
15564 tempguy->misc1=1;
15565 tempguy->weapon = ewFireTrail;
15566 }
15567
15568 break;
15569
15570 case 34: //eeZOLTRIB
15571 case 12: //eeZOL
15572 tempguy->misc4=tempguy->misc3;
15573 tempguy->misc3=tempguy->misc2;
15574 tempguy->family = eeWALK;
15575 tempguy->misc2=e2tSPLITHIT;
15576
15577 if(tempguy->misc1)
15578 {
15579 tempguy->misc1=1;
15580 tempguy->weapon = ewFireTrail;
15581 }
15582
15583 break;
15584
15585 case 13: //eeROPE
15586 tempguy->family = eeWALK;
15587 tempguy->misc9 = e9tROPE;
15588
15589 if(tempguy->misc1)
15590 {
15591 tempguy->misc4 = tempguy->misc3;
15592 tempguy->misc3 = tempguy->misc2;
15593 tempguy->misc2 = e2tBOMBCHU;
15594 }
15595
15596 tempguy->misc1 = 0;
15597 break;
15598
15599 case 14: //eeGORIYA
15600 tempguy->family = eeWALK;
15601
15602 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15603
15604 break;
15605
15606 case 17: //eeBUBBLE
15607 tempguy->family = eeWALK;
15608 tempguy->misc8 = tempguy->misc2;
15609 tempguy->misc7 = tempguy->misc1 + 1;
15610 tempguy->misc1 = tempguy->misc2 = 0;
15611
15612 //fallthrogh
15613 case eeTRAP:
15614 case eeROCK:
15615 doesntcount = true;
15616 break;
15617
15618 case 35: //eeVIRETRIB
15619 case 18: //eeVIRE
15620 tempguy->family = eeWALK;
15621 tempguy->misc4=tempguy->misc3;
15622 tempguy->misc3=tempguy->misc2;
15623 tempguy->misc2=e2tSPLITHIT;
15624 tempguy->misc9=e9tVIRE;
15625 break;
15626
15627 case 19: //eeLIKE
15628 tempguy->family = eeWALK;
15629 tempguy->misc7 = e7tEATITEMS;
15630 tempguy->misc8=95;
15631 break;
15632
15633 case 20: //eePOLSV
15634 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15635 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15636 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15637 tempguy->defense[edefARROW] = ed1HKO;
15638 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15639 tempguy->family = eeWALK;
15640 tempguy->misc9 = e9tPOLSVOICE;
15641 tempguy->rate = 4;
15642 tempguy->homing = 32;
15643 tempguy->hrate = 10;
15644 tempguy->grumble = 0;
15645 break;
15646
15647 case eeWIZZ:
15648 if(tempguy->misc4)
15649 {
15650 for(int32_t i=0; i < edefLAST; i++)
15651 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15652 }
15653 else
15654 {
15655 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15656 tempguy->defense[edefMAGIC] = edCHINK;
15657 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15658 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15659 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15660 }
15661
15662 break;
15663
15664 case eePEAHAT:
15665 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15666
15667 if(!(tempguy->flags & guy_bhit))
15668 tempguy->defense[edefBRANG] = edSTUNONLY;
15669
15670 break;
15671
15672 case eeLEV:
15673 tempguy->defense[edefSTOMP] = edCHINK;
15674 break;
15675 }
15676
15677 // Old flags
15678 if(tempguy->flags & guy_superman)
15679 {
15680 for(int32_t i = 0; i < edefLAST; i++)
15681 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15682 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15683 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15684 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15685 }
15686
15687 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15688
15689 if(doesntcount)
15690 tempguy->flags |= (guy_doesntcount);
15691 }
15692
15693
15694 187744 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15695 {
15696 byte tempbyte, padding;
15697 int32_t extras, secretcombos;
15698 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->valid),f,true))
15700 {
15701 return qe_invalid;
15702 }
15703
15704
15705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->guy),f,true))
15706 {
15707 return qe_invalid;
15708 }
15709
15710
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15711 {
15712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f,true))
15713 {
15714 return qe_invalid;
15715 }
15716
15717 6864 temp_mapscr->str=tempbyte;
15718 6864 }
15719 else
15720 {
15721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 if(!p_igetw(&(temp_mapscr->str),f,true))
15722 {
15723 return qe_invalid;
15724 }
15725 }
15726
15727
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->room),f,true))
15728 {
15729 return qe_invalid;
15730 }
15731
15732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->item),f,true))
15733 {
15734 return qe_invalid;
15735 }
15736
15737
3/6
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153000 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15738 {
15739 34744 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15740 34744 }
15741 else
15742 {
15743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15744 return qe_invalid;
15745 }
15746
15747
2/4
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
187744 if((Header->zelda_version < 0x192)||
15748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15749 {
15750
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f,true))
15751 {
15752 return qe_invalid;
15753 }
15754 6864 }
15755
15756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15757 {
15758 return qe_invalid;
15759 }
15760
15761
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
187744 if(Header->zelda_version < 0x193)
15762 {
15763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f,true))
15764 {
15765 return qe_invalid;
15766 }
15767 6864 }
15768
15769
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15770 {
15771
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15772 {
15773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15774 {
15775 return qe_invalid;
15776 }
15777 459000 }
15778 153000 }
15779 else
15780 {
15781 34744 temp_mapscr->tilewarptype[1]=0;
15782 34744 temp_mapscr->tilewarptype[2]=0;
15783 34744 temp_mapscr->tilewarptype[3]=0;
15784 }
15785
15786
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15787 {
15788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15789 {
15790 return qe_invalid;
15791 }
15792 180880 }
15793
15794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15795 {
15796 return qe_invalid;
15797 }
15798
15799 187744 temp_mapscr->warpreturnx[1]=0;
15800 187744 temp_mapscr->warpreturnx[2]=0;
15801 187744 temp_mapscr->warpreturnx[3]=0;
15802
15803
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15804 {
15805
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15806 {
15807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15808 {
15809 return qe_invalid;
15810 }
15811 459000 }
15812 153000 }
15813
15814
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15815 {
15816 return qe_invalid;
15817 }
15818
15819 187744 temp_mapscr->warpreturny[1]=0;
15820 187744 temp_mapscr->warpreturny[2]=0;
15821 187744 temp_mapscr->warpreturny[3]=0;
15822
15823
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15824 {
15825
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15826 {
15827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15828 {
15829 return qe_invalid;
15830 }
15831 459000 }
15832
15833
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(version>=18)
15834 {
15835
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15836 {
15837 return qe_invalid;
15838 }
15839 153000 }
15840 else
15841 {
15842 byte temp;
15843
15844 if(!p_getc(&temp,f,true))
15845 {
15846 return qe_invalid;
15847 }
15848
15849 temp_mapscr->warpreturnc=temp<<8|temp;
15850 }
15851 153000 }
15852
15853
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->stairx),f,true))
15854
15855 {
15856 return qe_invalid;
15857 }
15858
15859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->stairy),f,true))
15860 {
15861 return qe_invalid;
15862 }
15863
15864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->itemx),f,true))
15865 {
15866 return qe_invalid;
15867 }
15868
15869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->itemy),f,true))
15870 {
15871 return qe_invalid;
15872 }
15873
15874
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version > 15) // February 2009
15875 {
15876
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->color),f,true))
15877 {
15878 return qe_invalid;
15879 }
15880 153000 }
15881 else
15882 {
15883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34744 times.
34744 if(!p_getc(& tempbyte,f,true))
15884 {
15885 return qe_invalid;
15886 }
15887
15888 34744 temp_mapscr->color = (word) tempbyte;
15889 }
15890
15891
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15892 {
15893 return qe_invalid;
15894 }
15895
15896
2/2
✓ Branch 0 taken 750976 times.
✓ Branch 1 taken 187744 times.
938720 for(int32_t k=0; k<4; k++)
15897 {
15898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 750976 times.
750976 if(!p_getc(&(temp_mapscr->door[k]),f,true))
15899 {
15900 return qe_invalid;
15901
15902 }
15903 750976 }
15904
15905
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version <= 11)
15906 {
15907
1/2
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
34744 if(!p_getc(&(tempbyte),f,true))
15908 {
15909 return qe_invalid;
15910 }
15911
15912 34744 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15913
15914
2/6
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
34744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15915 {
15916 for(int32_t i=1; i<4; i++)
15917 {
15918 if(!p_getc(&(tempbyte),f,true))
15919 {
15920 return qe_invalid;
15921 }
15922
15923 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15924 }
15925 }
15926 else
15927 {
15928 34744 temp_mapscr->tilewarpdmap[1]=0;
15929 34744 temp_mapscr->tilewarpdmap[2]=0;
15930 34744 temp_mapscr->tilewarpdmap[3]=0;
15931 }
15932 34744 }
15933 else
15934 {
15935
2/2
✓ Branch 0 taken 612000 times.
✓ Branch 1 taken 153000 times.
765000 for(int32_t i=0; i<4; i++)
15936 {
15937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612000 times.
612000 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
15938 {
15939 return qe_invalid;
15940 }
15941 612000 }
15942 }
15943
15944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
15945 {
15946 return qe_invalid;
15947 }
15948
15949
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15950 {
15951
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
15952 {
15953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
15954 {
15955 return qe_invalid;
15956 }
15957 459000 }
15958 153000 }
15959 else
15960 {
15961 34744 temp_mapscr->tilewarpscr[1]=0;
15962 34744 temp_mapscr->tilewarpscr[2]=0;
15963 34744 temp_mapscr->tilewarpscr[3]=0;
15964 }
15965
15966
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version >= 15)
15967 {
15968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
15969 {
15970 return qe_invalid;
15971 }
15972 153000 }
15973 else
15974 {
15975 34744 temp_mapscr->tilewarpoverlayflags=0;
15976 }
15977
15978
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->exitdir),f,true))
15979 {
15980 return qe_invalid;
15981 }
15982
15983
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
187744 if(Header->zelda_version < 0x193)
15984 {
15985
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f,true))
15986 {
15987 return qe_invalid;
15988 }
15989
15990 6864 }
15991
15992
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15993 {
15994 if(!p_getc(&padding,f,true))
15995 {
15996 return qe_invalid;
15997 }
15998 }
15999
16000
2/2
✓ Branch 0 taken 1877440 times.
✓ Branch 1 taken 187744 times.
2065184 for(int32_t k=0; k<10; k++)
16001 {
16002 /*
16003 if (!temp_mapscr->enemy[k])
16004 {
16005 continue;
16006 }
16007 */
16008
3/6
✓ Branch 0 taken 1808800 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1808800 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1877440 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
16009 {
16010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f,true))
16011 {
16012 return qe_invalid;
16013 }
16014
16015 68640 temp_mapscr->enemy[k]=tempbyte;
16016 68640 }
16017 else
16018 {
16019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1808800 times.
1808800 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
16020 {
16021 return qe_invalid;
16022 }
16023 }
16024
16025
3/6
✓ Branch 0 taken 1808800 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1808800 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1877440 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
16026 {
16027 //using enumerations here is dangerous
16028 //very easy to break old quests -DD
16029
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
16030 {
16031 788 temp_mapscr->enemy[k]+=5;
16032 788 }
16033
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
16034 {
16035 40 temp_mapscr->enemy[k]+=1;
16036 40 }
16037 68640 }
16038
16039
2/2
✓ Branch 0 taken 1530000 times.
✓ Branch 1 taken 347440 times.
1877440 if(version < 9)
16040 {
16041
2/2
✓ Branch 0 taken 318415 times.
✓ Branch 1 taken 29025 times.
347440 if(temp_mapscr->enemy[k]>0)
16042 {
16043 29025 temp_mapscr->enemy[k]+=10;
16044 29025 }
16045 347440 }
16046 //don't read in any invalid data
16047
2/2
✓ Branch 0 taken 1877420 times.
✓ Branch 1 taken 20 times.
1877440 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
16048 {
16049 20 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
16050 20 temp_mapscr->enemy[k] = 0;
16051 20 }
16052 1877440 }
16053
16054
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->pattern),f,true))
16055 {
16056 return qe_invalid;
16057 }
16058
16059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
16060 {
16061 return qe_invalid;
16062 }
16063
16064
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16065 {
16066
2/2
✓ Branch 0 taken 459000 times.
✓ Branch 1 taken 153000 times.
612000 for(int32_t i=1; i<4; i++)
16067 {
16068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
16069 {
16070 return qe_invalid;
16071 }
16072 459000 }
16073 153000 }
16074 else
16075 {
16076 34744 temp_mapscr->sidewarptype[1]=0;
16077 34744 temp_mapscr->sidewarptype[2]=0;
16078 34744 temp_mapscr->sidewarptype[3]=0;
16079 }
16080
16081
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version >= 15)
16082 {
16083
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
16084 {
16085 return qe_invalid;
16086 }
16087 153000 }
16088 else
16089 {
16090 34744 temp_mapscr->sidewarpoverlayflags=0;
16091 }
16092
16093
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
16094 {
16095 return qe_invalid;
16096 }
16097
16098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
16099 {
16100 return qe_invalid;
16101 }
16102
16103
2/2
✓ Branch 0 taken 750976 times.
✓ Branch 1 taken 187744 times.
938720 for(int32_t k=0; k<4; k++)
16104 {
16105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 750976 times.
750976 if(!p_getc(&(temp_mapscr->path[k]),f,true))
16106 {
16107 return qe_invalid;
16108 }
16109 750976 }
16110
16111
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
16112 {
16113 return qe_invalid;
16114 }
16115
16116
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16117 {
16118
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 459000 times.
612000 for(int32_t i=1; i<4; i++)
16119 {
16120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459000 times.
459000 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
16121 {
16122 return qe_invalid;
16123 }
16124 459000 }
16125 153000 }
16126 else
16127 {
16128 34744 temp_mapscr->sidewarpscr[1]=0;
16129 34744 temp_mapscr->sidewarpscr[2]=0;
16130 34744 temp_mapscr->sidewarpscr[3]=0;
16131 }
16132
16133
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version <= 11)
16134 {
16135
1/2
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
34744 if(!p_getc(&(tempbyte),f,true))
16136 {
16137 return qe_invalid;
16138 }
16139
16140 34744 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16141
16142
2/6
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
34744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16143 {
16144 for(int32_t i=1; i<4; i++)
16145 {
16146 if(!p_getc(&(tempbyte),f,true))
16147 {
16148 return qe_invalid;
16149 }
16150
16151 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16152 }
16153 }
16154 else
16155 {
16156 34744 temp_mapscr->sidewarpdmap[1]=0;
16157 34744 temp_mapscr->sidewarpdmap[2]=0;
16158 34744 temp_mapscr->sidewarpdmap[3]=0;
16159 }
16160 34744 }
16161 else
16162 {
16163
2/2
✓ Branch 0 taken 612000 times.
✓ Branch 1 taken 153000 times.
765000 for(int32_t i=0; i<4; i++)
16164 {
16165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612000 times.
612000 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
16166 {
16167 return qe_invalid;
16168 }
16169 612000 }
16170 }
16171
16172
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16173 {
16174
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16175 {
16176 return qe_invalid;
16177 }
16178 153000 }
16179 34744 else temp_mapscr->sidewarpindex = 0;
16180
16181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16182 {
16183 return qe_invalid;
16184 }
16185
16186
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
187744 if(Header->zelda_version < 0x193)
16187 {
16188
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16189 {
16190 return qe_invalid;
16191 }
16192 6864 }
16193
16194
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16195 {
16196 return qe_invalid;
16197 }
16198
16199
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16200 {
16201 return qe_invalid;
16202 }
16203
16204
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(!p_getc(&(temp_mapscr->flags),f,true))
16205 {
16206 return qe_invalid;
16207 }
16208
16209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->flags2),f,true))
16210 {
16211 return qe_invalid;
16212 }
16213
16214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
187744 if(!p_getc(&(temp_mapscr->flags3),f,true))
16215 {
16216 return qe_invalid;
16217 }
16218
16219
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16220 //if (version>2)
16221 {
16222
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags4),f,true))
16223 {
16224 return qe_invalid;
16225 }
16226 153000 }
16227
16228
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16229 {
16230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->flags5),f,true))
16231 {
16232 return qe_invalid;
16233 }
16234
16235
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16236 {
16237 return qe_invalid;
16238 }
16239
16240
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16241 {
16242 return qe_invalid;
16243 }
16244
16245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(temp_mapscr->flags5&32)
16246 {
16247 temp_mapscr->flags5 &= ~32;
16248 temp_mapscr->noreset |= 48;
16249 }
16250
16251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(version<8)
16252 {
16253 if(temp_mapscr->noreset&1)
16254 {
16255 temp_mapscr->noreset|=8192;
16256 }
16257
16258 if(temp_mapscr->nocarry&1)
16259 {
16260 temp_mapscr->nocarry|=8192;
16261 temp_mapscr->nocarry&=~1;
16262 }
16263 }
16264 153000 }
16265 else
16266 {
16267 34744 temp_mapscr->flags5 = 0;
16268 34744 temp_mapscr->noreset = 0;
16269 34744 temp_mapscr->nocarry = 0;
16270 }
16271
16272
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16273 {
16274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->flags6),f,true))
16275 {
16276 return qe_invalid;
16277 }
16278 153000 }
16279
16280
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version>5)
16281 {
16282
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags7),f,true))
16283 {
16284 return qe_invalid;
16285 }
16286
16287
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags8),f,true))
16288 {
16289 return qe_invalid;
16290 }
16291
16292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->flags9),f,true))
16293 {
16294 return qe_invalid;
16295 }
16296
16297
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->flags10),f,true))
16298 {
16299 return qe_invalid;
16300 }
16301
16302
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16303 {
16304 return qe_invalid;
16305 }
16306 153000 }
16307 else
16308 {
16309 34744 temp_mapscr->csensitive=1;
16310 }
16311
16312
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version<14) // August 2007: screen SFX added
16313 {
16314
2/2
✓ Branch 0 taken 34644 times.
✓ Branch 1 taken 100 times.
34744 if(temp_mapscr->flags&8) //fROAR
16315 {
16316 100 temp_mapscr->bosssfx=
16317
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16318 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16319 WAV_ROAR;
16320 100 }
16321
16322
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 34653 times.
34744 if(temp_mapscr->flags&128) //fSEA
16323 {
16324 91 temp_mapscr->oceansfx=WAV_SEA;
16325 91 }
16326
16327 34744 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16328 ? 0 : WAV_SECRET;
16329
16330 34744 temp_mapscr->flags3 &= ~66; //64|2
16331 34744 temp_mapscr->flags2 &= ~32;
16332 34744 temp_mapscr->flags &= ~136; // 128|8
16333 34744 }
16334 else
16335 {
16336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16337 {
16338 return qe_invalid;
16339 }
16340
16341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16342 {
16343 return qe_invalid;
16344 }
16345
16346
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16347 {
16348 return qe_invalid;
16349 }
16350 }
16351
16352
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version<15) // October 2007: another SFX
16353 {
16354 34744 temp_mapscr->holdupsfx=WAV_PICKUP;
16355 34744 }
16356 else
16357 {
16358
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16359 {
16360 return qe_invalid;
16361 }
16362 }
16363
16364
16365
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16366 {
16367
2/2
✓ Branch 0 taken 1085280 times.
✓ Branch 1 taken 180880 times.
1266160 for(int32_t k=0; k<6; k++)
16368 {
16369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1085280 times.
1085280 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16370 {
16371 return qe_invalid;
16372 }
16373 1085280 }
16374
16375
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 1085280 times.
1266160 for(int32_t k=0; k<6; k++)
16376 {
16377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1085280 times.
1085280 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16378 {
16379 return qe_invalid;
16380 }
16381 1085280 }
16382 180880 }
16383
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16384 {
16385 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16386 {
16387 return qe_invalid;
16388 }
16389
16390 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16391 {
16392 return qe_invalid;
16393 }
16394
16395 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16396 {
16397 return qe_invalid;
16398 }
16399
16400 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16401
16402 {
16403 return qe_invalid;
16404 }
16405 }
16406
16407
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>149))
16408 {
16409 for(int32_t k=0; k<6; k++)
16410 {
16411 if(!p_getc(&tempbyte,f,true)) //layerxsize
16412 {
16413 return qe_invalid;
16414 }
16415 }
16416
16417 for(int32_t k=0; k<6; k++)
16418 {
16419 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16420 {
16421 return qe_invalid;
16422 }
16423 }
16424
16425 for(int32_t k=0; k<6; k++)
16426 {
16427 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16428 {
16429 return qe_invalid;
16430 }
16431 }
16432
16433 for(int32_t k=0; k<6; k++)
16434 {
16435 if(!p_getc(&tempbyte,f,true)) //layerysize
16436 {
16437 return qe_invalid;
16438 }
16439 }
16440
16441 for(int32_t k=0; k<6; k++)
16442 {
16443 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16444 {
16445 return qe_invalid;
16446 }
16447 }
16448
16449 for(int32_t k=0; k<6; k++)
16450 {
16451 if(!p_getc(&tempbyte,f,true)) //layerydelay
16452 {
16453 return qe_invalid;
16454 }
16455 }
16456 }
16457
16458
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16459 {
16460
2/2
✓ Branch 0 taken 1085280 times.
✓ Branch 1 taken 180880 times.
1266160 for(int32_t k=0; k<6; k++)
16461 {
16462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1085280 times.
1085280 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16463 {
16464 return qe_invalid;
16465 }
16466 1085280 }
16467 180880 }
16468
16469
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16470 {
16471
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 if((Header->zelda_version == 0x192)&&(Header->build>153))
16472 {
16473 if(!p_getc(&padding,f,true))
16474 {
16475 return qe_invalid;
16476 }
16477 }
16478
16479
1/2
✓ Branch 0 taken 180880 times.
✗ Branch 1 not taken.
180880 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16480 {
16481 return qe_invalid;
16482 }
16483 180880 }
16484
16485
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16486 {
16487 6864 extras=15;
16488 6864 }
16489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16490 {
16491 extras=11;
16492 }
16493
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16494 {
16495 extras=32;
16496 }
16497
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16498 {
16499 extras=64;
16500 }
16501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
180880 else if(Header->zelda_version < 0x193)
16502 {
16503 extras=62;
16504 }
16505 else
16506
16507 {
16508 180880 extras=0;
16509 }
16510
16511
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 187744 times.
290704 for(int32_t k=0; k<extras; k++)
16512 {
16513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f,true)) //extra[k]
16514 {
16515 return qe_invalid;
16516 }
16517 102960 }
16518
16519
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16520 //if (version>3)
16521 {
16522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16523 {
16524 return qe_invalid;
16525 }
16526
16527
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16528 {
16529 return qe_invalid;
16530 }
16531 153000 }
16532 else
16533 {
16534 34744 temp_mapscr->nextmap=0;
16535 34744 temp_mapscr->nextscr=0;
16536 }
16537
16538
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16539 {
16540 6864 secretcombos=20;
16541 6864 }
16542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180880 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16543 {
16544 secretcombos=256;
16545 }
16546 else
16547 {
16548 180880 secretcombos=128;
16549 }
16550
16551
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16552 {
16553
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16554 {
16555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f,true))
16556 {
16557 return qe_invalid;
16558 }
16559
16560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16561 {
16562 137280 temp_mapscr->secretcombo[k]=tempbyte;
16563 137280 }
16564 137280 }
16565 6864 }
16566 else
16567 {
16568
2/2
✓ Branch 0 taken 23152640 times.
✓ Branch 1 taken 180880 times.
23333520 for(int32_t k=0; k<128; k++)
16569 {
16570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23152640 times.
23152640 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16571 {
16572 return qe_invalid;
16573 }
16574
16575 23152640 }
16576 }
16577
16578
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16579 {
16580
2/2
✓ Branch 0 taken 23152640 times.
✓ Branch 1 taken 180880 times.
23333520 for(int32_t k=0; k<128; k++)
16581 {
16582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23152640 times.
23152640 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16583 {
16584 return qe_invalid;
16585 }
16586 23152640 }
16587
16588
2/2
✓ Branch 0 taken 23152640 times.
✓ Branch 1 taken 180880 times.
23333520 for(int32_t k=0; k<128; k++)
16589 {
16590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23152640 times.
23152640 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16591 {
16592 return qe_invalid;
16593 }
16594 23152640 }
16595 180880 }
16596
16597
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16598 {
16599 if(!p_getc(&padding,f,true))
16600 {
16601 return qe_invalid;
16602 }
16603 }
16604
16605 187744 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16606
16607
2/2
✓ Branch 0 taken 33042944 times.
✓ Branch 1 taken 187744 times.
33230688 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16608 {
16609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33042944 times.
33042944 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16610 {
16611 return qe_invalid;
16612 }
16613 33042944 }
16614
16615
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16616 {
16617 if(!p_getc(&padding,f,true))
16618 {
16619 return qe_invalid;
16620 }
16621
16622 if(!p_getc(&padding,f,true))
16623 {
16624 return qe_invalid;
16625 }
16626 }
16627
16628
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16629 {
16630
2/2
✓ Branch 0 taken 31834880 times.
✓ Branch 1 taken 180880 times.
32015760 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16631 {
16632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31834880 times.
31834880 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16633 {
16634 return qe_invalid;
16635 }
16636
16637
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31834880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31834880 if((Header->zelda_version == 0x192)&&(Header->build<24))
16638 {
16639 if(!p_getc(&tempbyte,f,true))
16640 {
16641 return qe_invalid;
16642 }
16643
16644 if(!p_getc(&tempbyte,f,true))
16645 {
16646 return qe_invalid;
16647 }
16648
16649 if(!p_getc(&tempbyte,f,true))
16650 {
16651 return qe_invalid;
16652 }
16653 }
16654 31834880 }
16655 180880 }
16656
16657
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16658 {
16659
2/2
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 31834880 times.
32015760 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16660 {
16661
16662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31834880 times.
31834880 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16663 {
16664 return qe_invalid;
16665 }
16666 31834880 }
16667 180880 }
16668
16669
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16670 {
16671 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16672 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16673 6864 }
16674
16675
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16676 {
16677 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16678 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16679 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16680 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16681 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16682 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16683 6864 }
16684
16685
3/6
✓ Branch 0 taken 180880 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187744 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16686 {
16687
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16688 {
16689
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16690 {
16691 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16692 {
16693 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16694 }
16695 }
16696 else
16697 {
16698
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16699 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16700 {
16701 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16702 1208064 }
16703
16704 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16705 }
16706
16707 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16708 1208064 }
16709 6864 }
16710
16711 /*if(version>12)
16712 {
16713 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16714 {
16715 return qe_invalid;
16716 }
16717 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16718 {
16719 return qe_invalid;
16720 }
16721 }*/
16722
16723
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version>4)
16724 {
16725
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16726 {
16727 return qe_invalid;
16728 }
16729 153000 }
16730 else
16731 {
16732 34744 temp_mapscr->screen_midi = -1;
16733 }
16734
16735
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version>=17)
16736 {
16737
1/2
✓ Branch 0 taken 153000 times.
✗ Branch 1 not taken.
153000 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16738 {
16739 return qe_invalid;
16740 }
16741 153000 }
16742 else
16743 {
16744 34744 temp_mapscr->lens_layer = llNORMAL;
16745 }
16746
16747
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 153000 times.
187744 if(version>6)
16748 {
16749 dword bits;
16750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153000 times.
153000 if(!p_igetl(&bits,f,true))
16751 {
16752 return qe_invalid;
16753 }
16754
16755 int32_t m;
16756 float tempfloat;
16757 word tempw;
16758 153000 temp_mapscr->ffcCountMarkDirty();
16759
16760
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 4896000 times.
5049000 for(m=0; m<32; m++)
16761 {
16762 4896000 ffcdata& tempffc = temp_mapscr->ffcs[m];
16763 4896000 tempffc.clear();
16764
2/2
✓ Branch 0 taken 4873014 times.
✓ Branch 1 taken 22986 times.
4896000 if((bits>>m)&1)
16765 {
16766
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(!p_igetw(&tempw,f,true))
16767 {
16768 return qe_invalid;
16769 }
16770 22986 tempffc.setData(tempw);
16771
16772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempffc.cset),f,true))
16773 {
16774 return qe_invalid;
16775 }
16776
16777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetw(&(tempffc.delay),f,true))
16778 {
16779 return qe_invalid;
16780 }
16781
16782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(version < 9)
16783 {
16784 if(!p_igetf(&tempfloat,f,true))
16785 {
16786 return qe_invalid;
16787 }
16788
16789 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16790
16791 if(!p_igetf(&tempfloat,f,true))
16792 {
16793 return qe_invalid;
16794 }
16795
16796 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16797
16798 if(!p_igetf(&tempfloat,f,true))
16799 {
16800 return qe_invalid;
16801 }
16802
16803 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16804
16805 if(!p_igetf(&tempfloat,f,true))
16806 {
16807 return qe_invalid;
16808 }
16809
16810 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16811
16812 if(!p_igetf(&tempfloat,f,true))
16813 {
16814 return qe_invalid;
16815 }
16816
16817 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16818
16819 if(!p_igetf(&tempfloat,f,true))
16820 {
16821 return qe_invalid;
16822 }
16823
16824 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16825 }
16826 else
16827 {
16828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.x),f,true))
16829 {
16830 return qe_invalid;
16831 }
16832
16833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.y),f,true))
16834 {
16835 return qe_invalid;
16836 }
16837
16838
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(!p_igetzf(&(tempffc.vx),f,true))
16839 {
16840 return qe_invalid;
16841 }
16842
16843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.vy),f,true))
16844 {
16845 return qe_invalid;
16846 }
16847
16848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.ax),f,true))
16849 {
16850 return qe_invalid;
16851 }
16852
16853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetzf(&(tempffc.ay),f,true))
16854 {
16855 return qe_invalid;
16856 }
16857 }
16858
16859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempffc.link),f,true))
16860 {
16861 return qe_invalid;
16862 }
16863
16864
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version>7)
16865 {
16866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&tempbyte,f,true))
16867 {
16868 return qe_invalid;
16869 }
16870
16871 22986 tempffc.hit_width = (tempbyte&0x3F)+1;
16872 22986 tempffc.txsz = (tempbyte>>6)+1;
16873
16874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&tempbyte,f,true))
16875 {
16876 return qe_invalid;
16877 }
16878
16879 22986 tempffc.hit_height = (tempbyte&0x3F)+1;
16880 22986 tempffc.tysz = (tempbyte>>6)+1;
16881
16882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.flags),f,true))
16883 {
16884 return qe_invalid;
16885 }
16886 22986 }
16887 else
16888 {
16889 tempffc.hit_width=16;
16890 tempffc.hit_height=16;
16891 tempffc.txsz=1;
16892 tempffc.tysz=1;
16893 tempffc.flags=0;
16894 }
16895
16896 22986 tempffc.updateSolid();
16897
16898
16899
4/6
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20966 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20966 times.
22986 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16900 {
16901 tempffc.flags|=ffIGNOREHOLDUP;
16902 }
16903
16904
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version>9)
16905 {
16906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetw(&(tempffc.script),f,true))
16907 {
16908 return qe_invalid;
16909 }
16910 22986 }
16911 else
16912 {
16913 tempffc.script=0;
16914 }
16915
16916
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version>10)
16917 {
16918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[0]),f,true))
16919 {
16920 return qe_invalid;
16921 }
16922
16923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[1]),f,true))
16924 {
16925 return qe_invalid;
16926 }
16927
16928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[2]),f,true))
16929 {
16930 return qe_invalid;
16931 }
16932
16933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[3]),f,true))
16934 {
16935 return qe_invalid;
16936 }
16937
16938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[4]),f,true))
16939 {
16940 return qe_invalid;
16941 }
16942
16943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[5]),f,true))
16944 {
16945 return qe_invalid;
16946 }
16947
16948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[6]),f,true))
16949 {
16950 return qe_invalid;
16951 }
16952
16953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_igetl(&(tempffc.initd[7]),f,true))
16954 {
16955 return qe_invalid;
16956 }
16957
16958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempbyte),f,true))
16959 {
16960 return qe_invalid;
16961 }
16962
16963 22986 tempffc.inita[0]=tempbyte*10000;
16964
16965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22986 times.
22986 if(!p_getc(&(tempbyte),f,true))
16966 {
16967 return qe_invalid;
16968 }
16969
16970 22986 tempffc.inita[1]=tempbyte*10000;
16971 22986 }
16972 else
16973 {
16974 tempffc.inita[0] = 10000;
16975 tempffc.inita[1] = 10000;
16976 }
16977
16978
1/2
✓ Branch 0 taken 22986 times.
✗ Branch 1 not taken.
22986 if(version <= 11)
16979 {
16980 fixffcs=true;
16981 }
16982 22986 }
16983 4896000 }
16984
16985 153000 }
16986
16987 //add in the new whistle flags
16988
2/2
✓ Branch 0 taken 153000 times.
✓ Branch 1 taken 34744 times.
187744 if(version<13)
16989 {
16990
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 34732 times.
34744 if(temp_mapscr->flags & fWHISTLE)
16991 {
16992 12 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16993 12 }
16994 34744 }
16995
16996 //2.55 starts here
16997
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 19 && Header->zelda_version > 0x253 )
16998 {
16999
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17000 {
17001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17002 {
17003 return qe_invalid;
17004 }
17005 137360 }
17006
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17007 {
17008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17009 {
17010 return qe_invalid;
17011 }
17012 137360 }
17013
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17014 {
17015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17016 {
17017 return qe_invalid;
17018 }
17019 137360 }
17020
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17021 {
17022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17023 {
17024 return qe_invalid;
17025 }
17026 137360 }
17027 13736 }
17028
3/4
✓ Branch 0 taken 174008 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 174008 times.
187744 if ( version < 19 && Header->zelda_version > 0x253 )
17029 {
17030 for ( int32_t q = 0; q < 10; q++ )
17031 {
17032 temp_mapscr->npcstrings[q] = 0;
17033 temp_mapscr->new_items[q] = 0;
17034 temp_mapscr->new_item_x[q] = 0;
17035 temp_mapscr->new_item_y[q] = 0;
17036 }
17037 }
17038
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 20 && Header->zelda_version > 0x253 )
17039 {
17040
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f,true))
17041 {
17042 return qe_invalid;
17043 }
17044
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
17045 {
17046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17047 {
17048 return qe_invalid;
17049 }
17050 109888 }
17051 13736 }
17052
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
187744 if ( version < 20 )
17053 {
17054 174008 temp_mapscr->script = 0;
17055
2/2
✓ Branch 0 taken 1392064 times.
✓ Branch 1 taken 174008 times.
1566072 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
17056 174008 }
17057
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 21 && Header->zelda_version > 0x253 )
17058 {
17059
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17060 {
17061 return qe_invalid;
17062 }
17063 13736 }
17064
2/2
✓ Branch 0 taken 174008 times.
✓ Branch 1 taken 13736 times.
187744 if ( version < 21 )
17065 {
17066 174008 temp_mapscr->preloadscript = 0;
17067 174008 }
17068 //all builds with version > 20 need this. -Z
17069
17070
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 174008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187744 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
17071 {
17072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
17073 {
17074 return qe_invalid;
17075 }
17076
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
17077 {
17078 return qe_invalid;
17079 }
17080 13736 }
17081
2/2
✓ Branch 0 taken 174008 times.
✓ Branch 1 taken 13736 times.
187744 if ( version < 22 )
17082 {
17083 174008 temp_mapscr->hidelayers = 0;
17084 174008 temp_mapscr->hidescriptlayers = 0;
17085 174008 }
17086
17087 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
17088 //May be any version before 2.11. -Z
17089 /* --not the roar, the HIT SFX
17090 if ( Header->zelda_version <= 0x210 )
17091 {
17092 if ( temp_mapscr->bosssfx == WAV_DODONGO )
17093 {
17094 temp_mapscr->bosssfx = WAV_ROAR;
17095 }
17096 }
17097 */
17098
17099 187744 return 0;
17100 187744 }
17101 202296 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
17102 {
17103
2/2
✓ Branch 0 taken 187744 times.
✓ Branch 1 taken 14552 times.
202296 if(version < 23)
17104 {
17105 187744 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
17106
1/2
✓ Branch 0 taken 187744 times.
✗ Branch 1 not taken.
187744 if(ret) return ret;
17107 187744 }
17108 else
17109 {
17110
1/2
✓ Branch 0 taken 14552 times.
✗ Branch 1 not taken.
14552 if(!p_getc(&(temp_mapscr->valid),f,true))
17111 return qe_invalid;
17112
2/2
✓ Branch 0 taken 5713 times.
✓ Branch 1 taken 8839 times.
14552 if(!(temp_mapscr->valid & mVALID))
17113 8839 return 0; //Empty screen
17114 uint32_t scr_has_flags;
17115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5713 times.
5713 if(!p_igetl(&scr_has_flags,f,true))
17116 return qe_invalid;
17117
17118
2/2
✓ Branch 0 taken 5653 times.
✓ Branch 1 taken 60 times.
5713 if(scr_has_flags & SCRHAS_ROOMDATA)
17119 {
17120
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&(temp_mapscr->guy),f,true))
17121 return qe_invalid;
17122
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&(temp_mapscr->str),f,true))
17123 return qe_invalid;
17124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(!p_getc(&(temp_mapscr->room),f,true))
17125 return qe_invalid;
17126
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&(temp_mapscr->catchall),f,true))
17127 return qe_invalid;
17128 60 }
17129
2/2
✓ Branch 0 taken 5604 times.
✓ Branch 1 taken 109 times.
5713 if(scr_has_flags & SCRHAS_ITEM)
17130 {
17131
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(!p_getc(&(temp_mapscr->item),f,true))
17132 return qe_invalid;
17133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(!p_getc(&(temp_mapscr->hasitem),f,true))
17134 return qe_invalid;
17135
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(!p_getc(&(temp_mapscr->itemx),f,true))
17136 return qe_invalid;
17137
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(!p_getc(&(temp_mapscr->itemy),f,true))
17138 return qe_invalid;
17139 109 }
17140
2/2
✓ Branch 0 taken 5375 times.
✓ Branch 1 taken 338 times.
5713 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17141 {
17142
1/2
✓ Branch 0 taken 338 times.
✗ Branch 1 not taken.
338 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
17143 return qe_invalid;
17144 338 }
17145
2/2
✓ Branch 0 taken 5488 times.
✓ Branch 1 taken 225 times.
5713 if(scr_has_flags & SCRHAS_TWARP)
17146 {
17147
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 225 times.
1125 for(int32_t i=0; i<4; i++)
17148 {
17149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
17150 return qe_invalid;
17151 900 }
17152
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 225 times.
1125 for(int32_t i=0; i<4; i++)
17153 {
17154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
17155 return qe_invalid;
17156 900 }
17157
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 225 times.
1125 for(int32_t i=0; i<4; i++)
17158 {
17159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
17160 return qe_invalid;
17161 900 }
17162
1/2
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
225 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17163 return qe_invalid;
17164 225 }
17165
2/2
✓ Branch 0 taken 5574 times.
✓ Branch 1 taken 139 times.
5713 if(scr_has_flags & SCRHAS_SWARP)
17166 {
17167
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17168 {
17169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17170 return qe_invalid;
17171 556 }
17172
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17173 {
17174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17175 return qe_invalid;
17176 556 }
17177
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17178 {
17179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17180 return qe_invalid;
17181 556 }
17182
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17183 return qe_invalid;
17184
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17185 return qe_invalid;
17186 139 }
17187
2/2
✓ Branch 0 taken 5371 times.
✓ Branch 1 taken 342 times.
5713 if(scr_has_flags & SCRHAS_WARPRET)
17188 {
17189
2/2
✓ Branch 0 taken 1368 times.
✓ Branch 1 taken 342 times.
1710 for(int32_t i=0; i<4; i++)
17190 {
17191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
1368 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17192 return qe_invalid;
17193 1368 }
17194
2/2
✓ Branch 0 taken 1368 times.
✓ Branch 1 taken 342 times.
1710 for(int32_t i=0; i<4; i++)
17195 {
17196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
1368 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17197 return qe_invalid;
17198 1368 }
17199
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17200 return qe_invalid;
17201
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17202 return qe_invalid;
17203 342 }
17204
2/2
✓ Branch 0 taken 1114 times.
✓ Branch 1 taken 4599 times.
5713 if(scr_has_flags & SCRHAS_LAYERS)
17205 {
17206
2/2
✓ Branch 0 taken 6684 times.
✓ Branch 1 taken 1114 times.
7798 for(int32_t k=0; k<6; k++)
17207 {
17208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6684 times.
6684 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17209 return qe_invalid;
17210 6684 }
17211
2/2
✓ Branch 0 taken 6684 times.
✓ Branch 1 taken 1114 times.
7798 for(int32_t k=0; k<6; k++)
17212 {
17213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6684 times.
6684 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17214 return qe_invalid;
17215 6684 }
17216
2/2
✓ Branch 0 taken 6684 times.
✓ Branch 1 taken 1114 times.
7798 for(int32_t k=0; k<6; k++)
17217 {
17218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6684 times.
6684 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17219 return qe_invalid;
17220 6684 }
17221
1/2
✓ Branch 0 taken 1114 times.
✗ Branch 1 not taken.
1114 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17222 return qe_invalid;
17223
1/2
✓ Branch 0 taken 1114 times.
✗ Branch 1 not taken.
1114 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17224 return qe_invalid;
17225 1114 }
17226 else
17227 {
17228
2/2
✓ Branch 0 taken 27594 times.
✓ Branch 1 taken 4599 times.
32193 for(int32_t k=0; k<6; k++)
17229 {
17230 27594 temp_mapscr->layeropacity[k] = 255;
17231 27594 }
17232 }
17233
1/2
✓ Branch 0 taken 5713 times.
✗ Branch 1 not taken.
5713 if(scr_has_flags & SCRHAS_MAZE)
17234 {
17235 for(int32_t k=0; k<4; k++)
17236 {
17237 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17238 return qe_invalid;
17239 }
17240 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17241 return qe_invalid;
17242 }
17243
2/2
✓ Branch 0 taken 5584 times.
✓ Branch 1 taken 129 times.
5713 if(scr_has_flags & SCRHAS_D_S_U)
17244 {
17245
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17246 return qe_invalid;
17247
2/2
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 129 times.
645 for(int32_t k=0; k<4; k++)
17248 {
17249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516 times.
516 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17250 return qe_invalid;
17251 516 }
17252
17253
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!p_getc(&(temp_mapscr->stairx),f,true))
17254 return qe_invalid;
17255
17256
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!p_getc(&(temp_mapscr->stairy),f,true))
17257 return qe_invalid;
17258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17259 return qe_invalid;
17260
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!p_getc(&(temp_mapscr->undercset),f,true))
17261 return qe_invalid;
17262 129 }
17263
2/2
✓ Branch 0 taken 5310 times.
✓ Branch 1 taken 403 times.
5713 if(scr_has_flags & SCRHAS_FLAGS)
17264 {
17265
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags),f,true))
17266 return qe_invalid;
17267
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags2),f,true))
17268 return qe_invalid;
17269
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags3),f,true))
17270 return qe_invalid;
17271
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags4),f,true))
17272 return qe_invalid;
17273
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags5),f,true))
17274 return qe_invalid;
17275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403 times.
403 if(!p_getc(&(temp_mapscr->flags6),f,true))
17276 return qe_invalid;
17277
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags7),f,true))
17278 return qe_invalid;
17279
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags8),f,true))
17280 return qe_invalid;
17281
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags9),f,true))
17282 return qe_invalid;
17283
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&(temp_mapscr->flags10),f,true))
17284 return qe_invalid;
17285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403 times.
403 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17286 return qe_invalid;
17287 403 }
17288
2/2
✓ Branch 0 taken 5348 times.
✓ Branch 1 taken 365 times.
5713 if(scr_has_flags & SCRHAS_ENEMY)
17289 {
17290
2/2
✓ Branch 0 taken 3650 times.
✓ Branch 1 taken 365 times.
4015 for(int32_t k=0; k<10; k++)
17291 {
17292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3650 times.
3650 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17293 return qe_invalid;
17294
1/2
✓ Branch 0 taken 3650 times.
✗ Branch 1 not taken.
3650 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17295 temp_mapscr->enemy[k] = 0;
17296 3650 }
17297
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if(!p_getc(&(temp_mapscr->pattern),f,true))
17298 return qe_invalid;
17299 365 }
17300
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 33 times.
5713 if(scr_has_flags & SCRHAS_CARRY)
17301 {
17302
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17303 return qe_invalid;
17304
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17305 return qe_invalid;
17306
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17307 return qe_invalid;
17308
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17309 return qe_invalid;
17310 33 }
17311
2/2
✓ Branch 0 taken 5682 times.
✓ Branch 1 taken 31 times.
5713 if(scr_has_flags & SCRHAS_SCRIPT)
17312 {
17313
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->script),f,true))
17314 return qe_invalid;
17315
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17316 return qe_invalid;
17317
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 31 times.
279 for ( int32_t q = 0; q < 8; q++ )
17318 {
17319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17320 return qe_invalid;
17321 248 }
17322 31 }
17323
1/2
✓ Branch 0 taken 5713 times.
✗ Branch 1 not taken.
5713 if(scr_has_flags & SCRHAS_UNUSED)
17324 {
17325 for ( int32_t q = 0; q < 10; q++ )
17326 {
17327 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17328 return qe_invalid;
17329 }
17330 for ( int32_t q = 0; q < 10; q++ )
17331 {
17332 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17333 return qe_invalid;
17334 }
17335 for ( int32_t q = 0; q < 10; q++ )
17336 {
17337 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17338 return qe_invalid;
17339 }
17340 for ( int32_t q = 0; q < 10; q++ )
17341 {
17342 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17343 return qe_invalid;
17344 }
17345 }
17346
2/2
✓ Branch 0 taken 5320 times.
✓ Branch 1 taken 393 times.
5713 if(scr_has_flags & SCRHAS_SECRETS)
17347 {
17348
2/2
✓ Branch 0 taken 50304 times.
✓ Branch 1 taken 393 times.
50697 for(int32_t k=0; k<128; k++)
17349 {
17350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50304 times.
50304 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17351 return qe_invalid;
17352 50304 }
17353
2/2
✓ Branch 0 taken 50304 times.
✓ Branch 1 taken 393 times.
50697 for(int32_t k=0; k<128; k++)
17354 {
17355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50304 times.
50304 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17356 return qe_invalid;
17357 50304 }
17358
2/2
✓ Branch 0 taken 50304 times.
✓ Branch 1 taken 393 times.
50697 for(int32_t k=0; k<128; k++)
17359 {
17360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50304 times.
50304 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17361 return qe_invalid;
17362 50304 }
17363 393 }
17364
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 2768 times.
5713 if(scr_has_flags & SCRHAS_COMBOFLAG)
17365 {
17366
2/2
✓ Branch 0 taken 487168 times.
✓ Branch 1 taken 2768 times.
489936 for(int32_t k=0; k<176; ++k)
17367 {
17368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 487168 times.
487168 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17369 return qe_invalid;
17370 487168 }
17371
2/2
✓ Branch 0 taken 487168 times.
✓ Branch 1 taken 2768 times.
489936 for(int32_t k=0; k<176; ++k)
17372 {
17373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 487168 times.
487168 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17374 return qe_invalid;
17375 487168 }
17376
2/2
✓ Branch 0 taken 487168 times.
✓ Branch 1 taken 2768 times.
489936 for(int32_t k=0; k<176; ++k)
17377 {
17378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 487168 times.
487168 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17379 return qe_invalid;
17380 487168 }
17381 2768 }
17382
1/2
✓ Branch 0 taken 5713 times.
✗ Branch 1 not taken.
5713 if(scr_has_flags & SCRHAS_MISC)
17383 {
17384
1/2
✓ Branch 0 taken 5713 times.
✗ Branch 1 not taken.
5713 if(!p_igetw(&(temp_mapscr->color),f,true))
17385 return qe_invalid;
17386
1/2
✓ Branch 0 taken 5713 times.
✗ Branch 1 not taken.
5713 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17387 return qe_invalid;
17388
1/2
✓ Branch 0 taken 5713 times.
✗ Branch 1 not taken.
5713 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17389 return qe_invalid;
17390
1/2
✓ Branch 0 taken 5713 times.
✗ Branch 1 not taken.
5713 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17391 return qe_invalid;
17392
1/2
✓ Branch 0 taken 5713 times.
✗ Branch 1 not taken.
5713 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17393 return qe_invalid;
17394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5713 times.
5713 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17395 return qe_invalid;
17396
1/2
✓ Branch 0 taken 5713 times.
✗ Branch 1 not taken.
5713 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17397 return qe_invalid;
17398
1/2
✓ Branch 0 taken 5713 times.
✗ Branch 1 not taken.
5713 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17399 return qe_invalid;
17400
1/2
✓ Branch 0 taken 5713 times.
✗ Branch 1 not taken.
5713 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17401 return qe_invalid;
17402 5713 }
17403 else
17404 {
17405 temp_mapscr->screen_midi = -1;
17406 temp_mapscr->csensitive = 1;
17407 }
17408 //FFC
17409 5713 bool old_ff = version < 25;
17410 5713 dword bits = 0;
17411 5713 word numffc = 32;
17412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5713 times.
5713 if(old_ff)
17413 {
17414 if(!p_igetl(&bits,f,true))
17415 return qe_invalid;
17416 }
17417 else
17418 {
17419
1/2
✓ Branch 0 taken 5713 times.
✗ Branch 1 not taken.
5713 if(!p_igetw(&numffc,f,true))
17420 return qe_invalid;
17421 }
17422 byte tempbyte;
17423 word tempw;
17424
4/6
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 5687 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
5713 static ffcdata nil_ffc;
17425 5713 temp_mapscr->ffcCountMarkDirty();
17426
2/2
✓ Branch 0 taken 5713 times.
✓ Branch 1 taken 7809 times.
13522 for(word m = 0; m < numffc; ++m)
17427 {
17428
1/2
✓ Branch 0 taken 7809 times.
✗ Branch 1 not taken.
7809 ffcdata& tempffc = (m < MAXFFCS)
17429 7809 ? temp_mapscr->ffcs[m]
17430 : nil_ffc; //sanity
17431 7809 tempffc.clear();
17432
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7809 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7809 if(old_ff && !(bits & (1<<m))) continue;
17433
17434
1/2
✓ Branch 0 taken 7809 times.
✗ Branch 1 not taken.
7809 if(!p_igetw(&tempw,f,true))
17435 return qe_invalid;
17436
3/4
✓ Branch 0 taken 7809 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1331 times.
✓ Branch 3 taken 6478 times.
7809 if(!old_ff && !tempw) //empty ffc, nothing more to load
17437 6478 continue;
17438 1331 tempffc.setData(tempw);
17439
17440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1331 times.
1331 if(!p_getc(&(tempffc.cset),f,true))
17441 return qe_invalid;
17442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1331 times.
1331 if(!p_igetw(&(tempffc.delay),f,true))
17443 return qe_invalid;
17444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1331 times.
1331 if(!p_igetzf(&(tempffc.x),f,true))
17445 return qe_invalid;
17446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1331 times.
1331 if(!p_igetzf(&(tempffc.y),f,true))
17447 return qe_invalid;
17448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1331 times.
1331 if(!p_igetzf(&(tempffc.vx),f,true))
17449 return qe_invalid;
17450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1331 times.
1331 if(!p_igetzf(&(tempffc.vy),f,true))
17451 return qe_invalid;
17452
1/2
✓ Branch 0 taken 1331 times.
✗ Branch 1 not taken.
1331 if(!p_igetzf(&(tempffc.ax),f,true))
17453 return qe_invalid;
17454
1/2
✓ Branch 0 taken 1331 times.
✗ Branch 1 not taken.
1331 if(!p_igetzf(&(tempffc.ay),f,true))
17455 return qe_invalid;
17456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1331 times.
1331 if(!p_getc(&(tempffc.link),f,true))
17457 return qe_invalid;
17458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1331 times.
1331 if(version < 24)
17459 {
17460 if(!p_getc(&tempbyte,f,true))
17461 return qe_invalid;
17462 tempffc.hit_width = (tempbyte&0x3F)+1;
17463 tempffc.txsz = (tempbyte>>6)+1;
17464 if(!p_getc(&tempbyte,f,true))
17465 return qe_invalid;
17466 tempffc.hit_height = (tempbyte&0x3F)+1;
17467 tempffc.tysz = (tempbyte>>6)+1;
17468 }
17469 else
17470 {
17471
1/2
✓ Branch 0 taken 1331 times.
✗ Branch 1 not taken.
1331 if(!p_igetl(&(tempffc.hit_width),f,true))
17472 return qe_invalid;
17473
1/2
✓ Branch 0 taken 1331 times.
✗ Branch 1 not taken.
1331 if(!p_igetl(&(tempffc.hit_height),f,true))
17474 return qe_invalid;
17475
1/2
✓ Branch 0 taken 1331 times.
✗ Branch 1 not taken.
1331 if(!p_getc(&(tempffc.txsz),f,true))
17476 return qe_invalid;
17477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1331 times.
1331 if(!p_getc(&(tempffc.tysz),f,true))
17478 return qe_invalid;
17479 }
17480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1331 times.
1331 if(!p_igetl(&(tempffc.flags),f,true))
17481 return qe_invalid;
17482 1331 tempffc.updateSolid();
17483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1331 times.
1331 if(!p_igetw(&(tempffc.script),f,true))
17484 return qe_invalid;
17485
2/2
✓ Branch 0 taken 10648 times.
✓ Branch 1 taken 1331 times.
11979 for(auto q = 0; q < 8; ++q)
17486 {
17487
1/2
✓ Branch 0 taken 10648 times.
✗ Branch 1 not taken.
10648 if(!p_igetl(&(tempffc.initd[q]),f,true))
17488 return qe_invalid;
17489 10648 }
17490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1331 times.
1331 if(!p_getc(&(tempbyte),f,true))
17491 return qe_invalid;
17492 1331 tempffc.inita[0]=tempbyte*10000;
17493
17494
1/2
✓ Branch 0 taken 1331 times.
✗ Branch 1 not taken.
1331 if(!p_getc(&(tempbyte),f,true))
17495 return qe_invalid;
17496 1331 tempffc.inita[1]=tempbyte*10000;
17497 1331 }
17498
2/2
✓ Branch 0 taken 723455 times.
✓ Branch 1 taken 5713 times.
729168 for(word m = numffc; m < MAXFFCS; ++m)
17499 {
17500 723455 temp_mapscr->ffcs[m].clear();
17501 723455 }
17502 //END FFC
17503 }
17504 193457 return 0;
17505 202296 }
17506
17507
17508 114 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17509 {
17510 114 int32_t scr=0;
17511
17512 114 word version=0;
17513 dword dummy;
17514 int32_t screens_to_read;
17515
17516 114 mapscr temp_mapscr;
17517 zcmap temp_map;
17518 word temp_map_count;
17519 dword section_size;
17520
17521
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17522 {
17523 4 screens_to_read=MAPSCRS192b136;
17524 4 }
17525 else
17526 {
17527 110 screens_to_read=MAPSCRS;
17528 }
17529
17530
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(Header->zelda_version > 0x192)
17531 {
17532 //section version info
17533
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&version,f,true))
17534 {
17535 return qe_invalid;
17536 }
17537
17538 110 FFCore.quest_format[vMaps] = version;
17539
17540 //al_trace("Maps version %d\n", version);
17541
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy,f,true))
17542 {
17543 return qe_invalid;
17544 }
17545
17546 //section size
17547
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&section_size,f,true))
17548 {
17549 return qe_invalid;
17550 }
17551
17552 //finally... section data
17553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(!p_igetw(&temp_map_count,f,true))
17554 {
17555 return 5;
17556 }
17557 110 }
17558 else
17559 {
17560 4 temp_map_count=map_count;
17561 }
17562
17563
17564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata)
17565 {
17566 114 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17567 114 TheMaps.resize(_mapsSize);
17568
17569
2/2
✓ Branch 0 taken 203456 times.
✓ Branch 1 taken 114 times.
203570 for(int32_t i(0); i<_mapsSize; i++)
17570 203456 TheMaps[i].zero_memory();
17571
17572 114 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17573 114 }
17574
17575 114 temp_mapscr.zero_memory();
17576
17577 114 memset(&temp_map, 0, sizeof(zcmap));
17578 114 temp_map.scrResWidth = 256;
17579 114 temp_map.scrResHeight = 224;
17580 114 temp_map.tileWidth = 16;
17581 114 temp_map.tileHeight = 11;
17582 114 temp_map.viewWidth = 256;
17583 114 temp_map.viewHeight = 176;
17584 114 temp_map.viewX = 0;
17585 114 temp_map.viewY = 64;
17586 114 temp_map.subaWidth = 256;
17587 114 temp_map.subaHeight = 168;
17588 114 temp_map.subaTrans = false;
17589 114 temp_map.subpWidth = 256;
17590 114 temp_map.subpHeight = 56;
17591 114 temp_map.subpTrans = false;
17592
4/4
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 1496 times.
✓ Branch 2 taken 1496 times.
✓ Branch 3 taken 114 times.
1610 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17593 {
17594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1496 times.
1496 if(keepdata==true) //!TODO Trim fully
17595 {
17596 1496 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17597 1496 }
17598 1496 byte valid=1;
17599
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 114 times.
1496 if(version > 22)
17600 {
17601
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&valid,f,true))
17602 return qe_invalid;
17603 114 }
17604
2/2
✓ Branch 0 taken 203248 times.
✓ Branch 1 taken 1496 times.
204744 for(int32_t j=0; j<screens_to_read; j++)
17605 {
17606 203248 scr=i*MAPSCRS+j;
17607 203248 clear_screen(&temp_mapscr);
17608
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 202296 times.
203248 if(valid)
17609 202296 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17610
17611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203248 times.
203248 if(keepdata==true)
17612 {
17613 203248 TheMaps[scr] = temp_mapscr;
17614 203248 }
17615 203248 }
17616
17617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1496 times.
1496 if(keepdata==true)
17618 {
17619
3/6
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1444 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1496 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17620 {
17621 52 int32_t index = (i*MAPSCRS+132);
17622
17623 52 TheMaps[index]=TheMaps[index-1];
17624
17625 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17626 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17627 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17628
17629
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17630 {
17631 156 scr=i*MAPSCRS+j;
17632
17633 156 TheMaps[scr].zero_memory();
17634 156 TheMaps[scr].valid = mVERSION;
17635 156 TheMaps[scr].screen_midi = -1;
17636 156 TheMaps[scr].csensitive = 1;
17637 156 }
17638 52 }
17639
17640
3/6
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1444 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1496 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17641 {
17642
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17643 {
17644 7072 scr=i*MAPSCRS+j;
17645 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17646
17647
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17648 {
17649 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17650 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17651 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17652 905216 }
17653 7072 }
17654 52 }
17655 1496 }
17656 1496 }
17657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata)
17658 {
17659 114 map_count = temp_map_count;
17660 114 }
17661 114 clear_screen(&temp_mapscr);
17662 114 return 0;
17663 114 }
17664
17665
17666 701689 void update_combo(newcombo& cmb, word section_version)
17667 {
17668
2/2
✓ Branch 0 taken 102480 times.
✓ Branch 1 taken 599209 times.
701689 if(section_version < 40)
17669 {
17670
3/3
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 11791 times.
✓ Branch 2 taken 586058 times.
599209 switch(cmb.type)
17671 {
17672 case cWATER: case cSHALLOWWATER:
17673 11791 cmb.attribytes[6] = iwRipples;
17674 11791 break;
17675 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17676 1360 cmb.attribytes[6] = iwTallGrass;
17677 1360 break;
17678 }
17679 599209 }
17680 701689 }
17681 87 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17682 {
17683 87 reset_combo_animations();
17684 87 reset_combo_animations2();
17685
17686 87 init_combo_classes();
17687
17688 // combos
17689 87 word combos_used=0;
17690 int32_t dummy;
17691 byte padding;
17692 87 newcombo temp_combo;
17693 //word section_cversion=0;
17694
17695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(keepdata==true)
17696 {
17697
2/2
✓ Branch 0 taken 5679360 times.
✓ Branch 1 taken 87 times.
5679447 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17698
1/2
✓ Branch 0 taken 5679360 times.
✗ Branch 1 not taken.
5679360 combobuf[q].clear();
17699 87 }
17700
17701 // if(version > 0x192)
17702 // {
17703 // //section version info
17704 // if(!p_igetw(&section_version,f,true))
17705 // {
17706 // return qe_invalid;
17707 // }
17708
17709 // FFCore.quest_format[vCombos] = section_version;
17710
17711 // //al_trace("Combos version %d\n", section_version);
17712 // if(!p_igetw(&section_cversion,f,true))
17713 // {
17714 // return qe_invalid;
17715 // }
17716
17717 // //section size
17718 // if(!p_igetl(&dummy,f,true))
17719 // {
17720 // return qe_invalid;
17721 // }
17722 // }
17723
17724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(version < 0x174)
17725 {
17726 combos_used=1024;
17727 }
17728
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
87 else if(version < 0x191)
17729 {
17730 4 combos_used=2048;
17731 4 }
17732 else
17733 {
17734
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 if(!p_igetw(&combos_used,f,true))
17735 {
17736 return qe_invalid;
17737 }
17738 }
17739
17740 //finally... section data
17741
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 516329 times.
516416 for(int32_t i=0; i<combos_used; i++)
17742 {
17743
1/2
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
516329 temp_combo.clear();
17744
17745
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if ( section_version >= 11 )
17746 {
17747
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.tile,f,true))
17748 {
17749 return qe_invalid;
17750 }
17751 68884 }
17752 else
17753 {
17754
2/4
✓ Branch 0 taken 447445 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 447445 times.
✗ Branch 3 not taken.
447445 if(!p_igetw(&temp_combo.tile,f,true))
17755 {
17756 return qe_invalid;
17757 }
17758 }
17759 516329 temp_combo.o_tile = temp_combo.tile;
17760
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(!p_getc(&temp_combo.flip,f,true))
17761 {
17762 return qe_invalid;
17763 }
17764
17765
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(!p_getc(&temp_combo.walk,f,true))
17766 {
17767 return qe_invalid;
17768 }
17769
17770
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(!p_getc(&temp_combo.type,f,true))
17771 {
17772 return qe_invalid;
17773 }
17774
17775
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(!p_getc(&temp_combo.csets,f,true))
17776 {
17777 return qe_invalid;
17778 }
17779
17780
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 508137 times.
516329 if(version < 0x193)
17781 {
17782
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f,true))
17783 return qe_invalid;
17784
17785
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f,true))
17786 return qe_invalid;
17787
17788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17789 {
17790
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17791 {
17792 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17793 {
17794 if(!p_getc(&padding,f,true))
17795 return qe_invalid;
17796 }
17797 }
17798 8192 }
17799 8192 }
17800
2/2
✓ Branch 0 taken 508137 times.
✓ Branch 1 taken 8192 times.
516329 if(version >= 0x192)
17801 {
17802
2/4
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508137 times.
✗ Branch 3 not taken.
508137 if(!p_getc(&temp_combo.frames,f,true))
17803 return qe_invalid;
17804
17805
2/4
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508137 times.
✗ Branch 3 not taken.
508137 if(!p_getc(&temp_combo.speed,f,true))
17806 return qe_invalid;
17807
17808
2/4
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508137 times.
✗ Branch 3 not taken.
508137 if(!p_igetw(&temp_combo.nextcombo,f,true))
17809 return qe_invalid;
17810
17811
2/4
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508137 times.
✗ Branch 3 not taken.
508137 if(!p_getc(&temp_combo.nextcset,f,true))
17812 return qe_invalid;
17813
17814 //Base flag
17815
2/2
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 109114 times.
508137 if(section_version>=3)
17816
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_getc(&temp_combo.flag,f,true))
17817 return qe_invalid;
17818
17819
2/2
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 109114 times.
508137 if(section_version>=4)
17820 {
17821
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_getc(&temp_combo.skipanim,f,true))
17822 return qe_invalid;
17823
17824
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_igetw(&temp_combo.nexttimer,f,true))
17825 return qe_invalid;
17826 399023 }
17827
17828
2/2
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 109114 times.
508137 if(section_version>=5)
17829
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_getc(&temp_combo.skipanimy,f,true))
17830 return qe_invalid;
17831
17832
2/2
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 109114 times.
508137 if(section_version>=6)
17833 {
17834
2/4
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399023 times.
✗ Branch 3 not taken.
399023 if(!p_getc(&temp_combo.animflags,f,true))
17835 return qe_invalid;
17836
17837
1/2
✓ Branch 0 taken 399023 times.
✗ Branch 1 not taken.
399023 if(section_version == 6)
17838 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17839 399023 }
17840
17841
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=8) //combo Attributes[4] and userflags.
17842 {
17843
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 275536 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17844
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f,true))
17845 return qe_invalid;
17846
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f,true))
17847 return qe_invalid;
17848
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17849
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f,true))
17850 return qe_invalid;
17851 68884 }
17852
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version>=10) //combo trigger flags
17853 {
17854
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17855
2/4
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206652 times.
✗ Branch 3 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17856 return qe_invalid;
17857 68884 }
17858
1/2
✓ Branch 0 taken 439253 times.
✗ Branch 1 not taken.
439253 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17859 {
17860 for ( int32_t q = 0; q < 2; q++ )
17861 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17862 return qe_invalid;
17863 }
17864
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version >= 9)
17865
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17866 return qe_invalid;
17867
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version >= 22)
17868
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f,true))
17869 return qe_invalid;
17870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 24)
17871 {
17872 if(!p_getc(&temp_combo.triggeritem,f,true))
17873 return qe_invalid;
17874 if(!p_getc(&temp_combo.trigtimer,f,true))
17875 return qe_invalid;
17876 }
17877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 25)
17878 if(!p_getc(&temp_combo.trigsfx,f,true))
17879 return qe_invalid;
17880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 27)
17881 if(!p_igetl(&temp_combo.trigchange,f,true))
17882 return qe_invalid;
17883
17884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 29)
17885 {
17886 if(!p_igetw(&temp_combo.trigprox,f,true))
17887 return qe_invalid;
17888 if(!p_getc(&temp_combo.trigctr,f,true))
17889 return qe_invalid;
17890 if(!p_igetl(&temp_combo.trigctramnt,f,true))
17891 return qe_invalid;
17892 }
17893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 30)
17894 if(!p_getc(&temp_combo.triglbeam,f,true))
17895 return qe_invalid;
17896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 31)
17897 {
17898 if(!p_getc(&temp_combo.trigcschange,f,true))
17899 return qe_invalid;
17900 if(!p_igetw(&temp_combo.spawnitem,f,true))
17901 return qe_invalid;
17902 if(!p_igetw(&temp_combo.spawnenemy,f,true))
17903 return qe_invalid;
17904 if(!p_getc(&temp_combo.exstate,f,true))
17905 return qe_invalid;
17906 if(!p_igetl(&temp_combo.spawnip,f,true))
17907 return qe_invalid;
17908 if(!p_getc(&temp_combo.trigcopycat,f,true))
17909 return qe_invalid;
17910 }
17911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508137 times.
508137 if(section_version >= 32)
17912 if(!p_getc(&temp_combo.trigcooldown,f,true))
17913 return qe_invalid;
17914
17915
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=12) //combo label
17916 {
17917 char label[12];
17918 68884 label[11] = '\0';
17919
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 757724 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17920
2/4
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757724 times.
✗ Branch 3 not taken.
757724 if(!p_getc(&label[q],f,true))
17921 return qe_invalid;
17922
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 temp_combo.label = label;
17923 68884 }
17924
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=13) //attribytes[4]
17925
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17926
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17927 68884 return qe_invalid;
17928 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17929 * This fixes a poor implementation of a ->next flag bug thing.
17930 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17931 * there was a version bump a few weeks before a change that broke stuff.
17932 */
17933
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68884 times.
508137 if (section_version >= 13 && section_version < 21)
17934 {
17935 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17936 }
17937 //combo scripts
17938
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version>=14)
17939 {
17940
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.script,f,true))
17941 return qe_invalid;
17942
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17943
2/4
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137768 times.
✗ Branch 3 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f,true))
17944 return qe_invalid;
17945 68884 }
17946 //al_trace("Read combo script data\n");
17947
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439253 times.
508137 if(section_version>=15)
17948 {
17949
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
17950
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17951
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
17952
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
17953 68884 }
17954
2/2
✓ Branch 0 taken 439253 times.
✓ Branch 1 taken 68884 times.
508137 if(section_version>=17) //attribytes[4]
17955 {
17956
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17957
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17958 return qe_invalid;
17959
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17960
2/4
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551072 times.
✗ Branch 3 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
17961 return qe_invalid;
17962 68884 }
17963
17964
1/2
✓ Branch 0 taken 508137 times.
✗ Branch 1 not taken.
508137 if(version < 0x193)
17965 for(int32_t q=0; q<11; q++)
17966 if(!p_getc(&dummy,f,true))
17967 return qe_invalid;
17968 508137 }
17969
17970 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17971
3/6
✓ Branch 0 taken 399023 times.
✓ Branch 1 taken 117306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399023 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
516329 if((version < 0x211)||((version == 0x211)&&(build<7)))
17972 {
17973
3/4
✓ Branch 0 taken 117306 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 109114 times.
✓ Branch 3 taken 8192 times.
117306 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
17974 {
17975
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17976 {
17977 case 130:
17978 temp_combo.tile = 132;
17979 break;
17980
17981 case 131:
17982 temp_combo.tile = 133;
17983 break;
17984
17985 case 132:
17986 temp_combo.tile = 130;
17987 break;
17988
17989 case 133:
17990 temp_combo.tile = 131;
17991 break;
17992 }
17993 8192 }
17994 117306 }
17995
17996
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version < 15)
17997 447445 temp_combo.o_tile = temp_combo.tile;
17998
17999
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version<18) //upper bits for .walk
18000 447445 temp_combo.walk |= 0xF0;
18001
18002
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version < 19)
18003
2/2
✓ Branch 0 taken 1789780 times.
✓ Branch 1 taken 447445 times.
2237225 for(int32_t q = 0; q < 4; ++q)
18004 2237225 temp_combo.attributes[q] *= 10000L;
18005
18006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 23)
18007 {
18008
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 515945 times.
516329 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
18009 {
18010 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
18011 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
18012 case cTRIGGERGENERIC: case cCSWITCH:
18013 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
18014 384 }
18015 516329 }
18016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 25)
18017 {
18018
2/2
✓ Branch 0 taken 2648 times.
✓ Branch 1 taken 513681 times.
516329 switch(temp_combo.type)
18019 {
18020 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2648 times.
2648 if(!(temp_combo.usrflags & cflag3))
18022 2648 temp_combo.attribytes[3] = WAV_DOOR;
18023 2648 temp_combo.usrflags &= ~cflag3;
18024 2648 break;
18025 }
18026 516329 }
18027
18028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 26)
18029
2/2
✓ Branch 0 taken 515799 times.
✓ Branch 1 taken 530 times.
516859 if(temp_combo.type == cARMOS)
18030
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 if(temp_combo.usrflags & cflag1)
18031 temp_combo.usrflags |= cflag3;
18032
18033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 27)
18034 {
18035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
18036 temp_combo.trigchange = 1;
18037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
18038 temp_combo.trigchange = -1;
18039 516329 else temp_combo.trigchange = 0;
18040 516329 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
18041 516329 }
18042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516329 times.
516329 if(section_version < 28)
18043 {
18044
2/2
✓ Branch 0 taken 1409 times.
✓ Branch 1 taken 514920 times.
516329 switch(temp_combo.type)
18045 {
18046 case cLOCKBLOCK: case cLOCKEDCHEST:
18047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1409 times.
1409 if(temp_combo.usrflags & cflag7)
18048 temp_combo.usrflags |= cflag8;
18049 1409 else temp_combo.usrflags &= ~cflag8;
18050 1409 temp_combo.usrflags &= ~cflag7;
18051 1409 break;
18052 }
18053
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 516260 times.
516329 switch(temp_combo.type)
18054 {
18055 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18056 69 temp_combo.attrishorts[2] = -1;
18057 69 temp_combo.usrflags |= cflag7;
18058 69 break;
18059 }
18060 516329 }
18061
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447445 times.
516329 if(section_version < 20)
18062 {
18063 447445 temp_combo.genflags = 0;
18064
2/2
✓ Branch 0 taken 17523 times.
✓ Branch 1 taken 429922 times.
447445 switch(temp_combo.type)
18065 {
18066 case cPUSH_WAIT: case cPUSH_HEAVY:
18067 case cPUSH_HW: case cL_STATUE:
18068 case cR_STATUE: case cPUSH_HEAVY2:
18069 case cPUSH_HW2: case cPOUND:
18070 case cC_STATUE: case cMIRROR:
18071 case cMIRRORSLASH: case cMIRRORBACKSLASH:
18072 case cMAGICPRISM: case cMAGICPRISM4:
18073 case cMAGICSPONGE: case cEYEBALL_A:
18074 case cEYEBALL_B: case cEYEBALL_4:
18075 case cBUSH: case cFLOWERS:
18076 case cLOCKBLOCK: case cLOCKBLOCK2:
18077 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
18078 case cCHEST: case cCHEST2:
18079 case cLOCKEDCHEST: case cLOCKEDCHEST2:
18080 case cBOSSCHEST: case cBOSSCHEST2:
18081 case cBUSHNEXT: case cBUSHTOUCHY:
18082 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
18083 case cSIGNPOST: case cCSWITCHBLOCK:
18084 case cTORCH: case cTRIGGERGENERIC:
18085
1/2
✓ Branch 0 taken 17523 times.
✗ Branch 1 not taken.
17523 if(temp_combo.usrflags & cflag16)
18086 {
18087 temp_combo.genflags |= cflag1;
18088 temp_combo.usrflags &= ~cflag16;
18089 }
18090 17523 break;
18091 }
18092 447445 }
18093
18094 516329 update_combo(temp_combo, section_version);
18095
18096
2/4
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516329 times.
✗ Branch 3 not taken.
516329 if(keepdata==true && i>=start_combo)
18097 {
18098
1/2
✓ Branch 0 taken 516329 times.
✗ Branch 1 not taken.
516329 combobuf[i] = temp_combo;
18099 516329 }
18100 516329 }
18101
18102
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if(keepdata==true)
18103 {
18104
3/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
87 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18105 {
18106
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18107 {
18108
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18109 {
18110 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18111 }
18112 261120 }
18113 4 }
18114
18115 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18116
4/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
87 if(version == 0x210 && !is_zquest())
18117 {
18118
2/2
✓ Branch 0 taken 326400 times.
✓ Branch 1 taken 5 times.
326405 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18119
2/2
✓ Branch 0 taken 326398 times.
✓ Branch 1 taken 2 times.
326402 if(combobuf[tmpcounter].type == cLADDERONLY)
18120 2 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18121 5 }
18122
18123
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 9 times.
87 if(section_version<7)
18124 {
18125
2/2
✓ Branch 0 taken 587520 times.
✓ Branch 1 taken 9 times.
587529 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18126 {
18127
6/9
✓ Branch 0 taken 587349 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
587520 switch(combobuf[tmpcounter].type)
18128 {
18129 case cSLASH:
18130 61 combobuf[tmpcounter].type=cSLASHTOUCHY;
18131 61 break;
18132
18133 case cSLASHITEM:
18134 62 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18135 62 break;
18136
18137 case cBUSH:
18138 28 combobuf[tmpcounter].type=cBUSHTOUCHY;
18139 28 break;
18140
18141 case cFLOWERS:
18142 10 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18143 10 break;
18144
18145 case cTALLGRASS:
18146 10 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18147 10 break;
18148
18149 case cSLASHNEXT:
18150 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18151 break;
18152
18153 case cSLASHNEXTITEM:
18154 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18155 break;
18156
18157 case cBUSHNEXT:
18158 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18159 break;
18160 }
18161 587520 }
18162 9 }
18163
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 85 times.
87 if (section_version < 16)
18164 {
18165
2/2
✓ Branch 0 taken 5548800 times.
✓ Branch 1 taken 85 times.
5548885 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18166 {
18167
2/2
✓ Branch 0 taken 5543143 times.
✓ Branch 1 taken 5657 times.
5548800 if (combobuf[tmpcounter].type == cWATER)
18168 {
18169 5657 combobuf[tmpcounter].attributes[0] = 40000L;
18170 5657 }
18171 5548800 }
18172 85 }
18173
3/4
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 1 times.
87 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18174 {
18175 1 combobuf[0].walk = 0xF0;
18176 1 combobuf[0].type = 0;
18177 1 combobuf[0].flag = 0;
18178 1 }
18179 87 }
18180
18181 //Now for the new combo alias reset
18182
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
87 if(section_version<2 && keepdata)
18183 {
18184
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9 times.
73737 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18185 {
18186 73728 combo_aliases[j].width = 0;
18187 73728 combo_aliases[j].height = 0;
18188 73728 combo_aliases[j].layermask = 0;
18189
18190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(combo_aliases[j].combos != NULL)
18191 {
18192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 delete[] combo_aliases[j].combos;
18193 73728 }
18194
18195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(combo_aliases[j].csets != NULL)
18196 {
18197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 delete[] combo_aliases[j].csets;
18198 73728 }
18199
18200
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 combo_aliases[j].combos = new word[1];
18201
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 combo_aliases[j].csets = new byte[1];
18202 73728 combo_aliases[j].combos[0] = 0;
18203 73728 combo_aliases[j].csets[0] = 0;
18204 73728 }
18205 9 }
18206
18207
18208
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 setup_combo_animations();
18209
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 setup_combo_animations2();
18210 87 return 0;
18211 87 }
18212 185360 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18213 {
18214 byte combo_has_flags;
18215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185360 times.
185360 if(!p_getc(&combo_has_flags,f,true))
18216 return qe_invalid;
18217
18218 185360 temp_combo.clear();
18219
2/2
✓ Branch 0 taken 120371 times.
✓ Branch 1 taken 64989 times.
185360 if(combo_has_flags)
18220 {
18221
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 64986 times.
64989 if(combo_has_flags&CHAS_BASIC)
18222 {
18223
1/2
✓ Branch 0 taken 64986 times.
✗ Branch 1 not taken.
64986 if(!p_igetl(&temp_combo.tile,f,true))
18224 {
18225 return qe_invalid;
18226 }
18227 64986 temp_combo.o_tile = temp_combo.tile;
18228
18229
1/2
✓ Branch 0 taken 64986 times.
✗ Branch 1 not taken.
64986 if(!p_getc(&temp_combo.flip,f,true))
18230 {
18231 return qe_invalid;
18232 }
18233
18234
1/2
✓ Branch 0 taken 64986 times.
✗ Branch 1 not taken.
64986 if(!p_getc(&temp_combo.walk,f,true))
18235 {
18236 return qe_invalid;
18237 }
18238
18239
1/2
✓ Branch 0 taken 64986 times.
✗ Branch 1 not taken.
64986 if(!p_getc(&temp_combo.type,f,true))
18240 {
18241 return qe_invalid;
18242 }
18243
18244
1/2
✓ Branch 0 taken 64986 times.
✗ Branch 1 not taken.
64986 if(!p_getc(&temp_combo.flag,f,true))
18245 {
18246 return qe_invalid;
18247 }
18248
18249
1/2
✓ Branch 0 taken 64986 times.
✗ Branch 1 not taken.
64986 if(!p_getc(&temp_combo.csets,f,true))
18250 {
18251 return qe_invalid;
18252 }
18253 64986 }
18254
2/2
✓ Branch 0 taken 64966 times.
✓ Branch 1 taken 23 times.
64989 if(combo_has_flags&CHAS_SCRIPT)
18255 {
18256
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 15 times.
23 if (s_version>=41)
18257 {
18258 8 p_getcstr(&temp_combo.label, f, true);
18259 8 }
18260 else
18261 {
18262 char label[12];
18263 15 label[11] = '\0';
18264
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 15 times.
180 for ( int32_t q = 0; q < 11; q++ )
18265 {
18266
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&label[q],f,true))
18267 {
18268 return qe_invalid;
18269 }
18270 165 }
18271 15 temp_combo.label = label;
18272 }
18273
18274
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18275
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 23 times.
69 for ( int32_t q = 0; q < 2; q++ )
18276 {
18277
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(!p_igetl(&temp_combo.initd[q],f,true))
18278 {
18279 return qe_invalid;
18280 }
18281 46 }
18282 23 }
18283
2/2
✓ Branch 0 taken 46482 times.
✓ Branch 1 taken 18507 times.
64989 if(combo_has_flags&CHAS_ANIM)
18284 {
18285
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_getc(&temp_combo.frames,f,true))
18286 {
18287 return qe_invalid;
18288 }
18289
18290
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_getc(&temp_combo.speed,f,true))
18291 {
18292 return qe_invalid;
18293 }
18294
18295
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_igetw(&temp_combo.nextcombo,f,true))
18296 {
18297 return qe_invalid;
18298 }
18299
18300
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_getc(&temp_combo.nextcset,f,true))
18301 {
18302 return qe_invalid;
18303 }
18304
18305
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_getc(&temp_combo.skipanim,f,true))
18306 {
18307 return qe_invalid;
18308 }
18309
18310
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_getc(&temp_combo.skipanimy,f,true))
18311 {
18312 return qe_invalid;
18313 }
18314
18315
1/2
✓ Branch 0 taken 18507 times.
✗ Branch 1 not taken.
18507 if(!p_getc(&temp_combo.animflags,f,true))
18316 {
18317 return qe_invalid;
18318 }
18319 18507 }
18320
2/2
✓ Branch 0 taken 57338 times.
✓ Branch 1 taken 7651 times.
64989 if(combo_has_flags&CHAS_ATTRIB)
18321 {
18322
2/2
✓ Branch 0 taken 30604 times.
✓ Branch 1 taken 7651 times.
38255 for ( int32_t q = 0; q < 4; q++ )
18323 {
18324
1/2
✓ Branch 0 taken 30604 times.
✗ Branch 1 not taken.
30604 if(!p_igetl(&temp_combo.attributes[q],f,true))
18325 {
18326 return qe_invalid;
18327 }
18328 30604 }
18329
2/2
✓ Branch 0 taken 61208 times.
✓ Branch 1 taken 7651 times.
68859 for ( int32_t q = 0; q < 8; q++ )
18330 {
18331
1/2
✓ Branch 0 taken 61208 times.
✗ Branch 1 not taken.
61208 if(!p_getc(&temp_combo.attribytes[q],f,true))
18332 {
18333 return qe_invalid;
18334 }
18335 61208 }
18336
2/2
✓ Branch 0 taken 61208 times.
✓ Branch 1 taken 7651 times.
68859 for ( int32_t q = 0; q < 8; q++ )
18337 {
18338
1/2
✓ Branch 0 taken 61208 times.
✗ Branch 1 not taken.
61208 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18339 {
18340 return qe_invalid;
18341 }
18342 61208 }
18343 7651 }
18344
2/2
✓ Branch 0 taken 63265 times.
✓ Branch 1 taken 1724 times.
64989 if(combo_has_flags&CHAS_FLAG)
18345 {
18346
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
1724 if(!p_igetl(&temp_combo.usrflags,f,true))
18347 {
18348 return qe_invalid;
18349 }
18350
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
1724 if(!p_igetw(&temp_combo.genflags,f,true))
18351 {
18352 return qe_invalid;
18353 }
18354 1724 }
18355
2/2
✓ Branch 0 taken 64469 times.
✓ Branch 1 taken 520 times.
64989 if(combo_has_flags&CHAS_TRIG)
18356 {
18357 520 int numtrigs = s_version < 36 ? 3 : 6;
18358
2/2
✓ Branch 0 taken 2691 times.
✓ Branch 1 taken 520 times.
3211 for ( int32_t q = 0; q < numtrigs; q++ )
18359 {
18360
1/2
✓ Branch 0 taken 2691 times.
✗ Branch 1 not taken.
2691 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18361 {
18362 return qe_invalid;
18363 }
18364 2691 }
18365
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18366 {
18367 return qe_invalid;
18368 }
18369
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.triggerbtn,f,true))
18370 {
18371 return qe_invalid;
18372 }
18373
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.triggeritem,f,true))
18374 {
18375 return qe_invalid;
18376 }
18377
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.trigtimer,f,true))
18378 {
18379 return qe_invalid;
18380 }
18381
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.trigsfx,f,true))
18382 {
18383 return qe_invalid;
18384 }
18385
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetl(&temp_combo.trigchange,f,true))
18386 {
18387 return qe_invalid;
18388 }
18389
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetw(&temp_combo.trigprox,f,true))
18390 {
18391 return qe_invalid;
18392 }
18393
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.trigctr,f,true))
18394 {
18395 return qe_invalid;
18396 }
18397
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18398 {
18399 return qe_invalid;
18400 }
18401
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.triglbeam,f,true))
18402 {
18403 return qe_invalid;
18404 }
18405
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.trigcschange,f,true))
18406 {
18407 return qe_invalid;
18408 }
18409
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetw(&temp_combo.spawnitem,f,true))
18410 {
18411 return qe_invalid;
18412 }
18413
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18414 {
18415 return qe_invalid;
18416 }
18417
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.exstate,f,true))
18418 {
18419 return qe_invalid;
18420 }
18421
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetl(&temp_combo.spawnip,f,true))
18422 {
18423 return qe_invalid;
18424 }
18425
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.trigcopycat,f,true))
18426 {
18427 return qe_invalid;
18428 }
18429
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.trigcooldown,f,true))
18430 {
18431 return qe_invalid;
18432 }
18433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520 times.
520 if(s_version >= 35)
18434 {
18435
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18436 {
18437 return qe_invalid;
18438 }
18439
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_getc(&temp_combo.prompt_cs,f,true))
18440 {
18441 return qe_invalid;
18442 }
18443
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetw(&temp_combo.prompt_x,f,true))
18444 {
18445 return qe_invalid;
18446 }
18447
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 if(!p_igetw(&temp_combo.prompt_y,f,true))
18448 {
18449 return qe_invalid;
18450 }
18451 520 }
18452
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 377 times.
520 if(s_version >= 36)
18453 {
18454
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 if(!p_getc(&temp_combo.trig_lstate,f,true))
18455 {
18456 return qe_invalid;
18457 }
18458
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 if(!p_getc(&temp_combo.trig_gstate,f,true))
18459 {
18460 return qe_invalid;
18461 }
18462
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 if(!p_igetl(&temp_combo.trig_statetime,f,true))
18463 {
18464 return qe_invalid;
18465 }
18466 377 }
18467
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 377 times.
520 if(s_version >= 37)
18468 {
18469
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 if(!p_igetw(&temp_combo.trig_genscr,f,true))
18470 {
18471 return qe_invalid;
18472 }
18473 377 }
18474
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 303 times.
520 if(s_version >= 38)
18475 {
18476
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 if(!p_getc(&temp_combo.trig_group,f,true))
18477 {
18478 return qe_invalid;
18479 }
18480
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 if(!p_igetw(&temp_combo.trig_group_val,f,true))
18481 {
18482 return qe_invalid;
18483 }
18484 303 }
18485 520 }
18486
2/2
✓ Branch 0 taken 64874 times.
✓ Branch 1 taken 115 times.
64989 if(combo_has_flags&CHAS_LIFT)
18487 {
18488
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&temp_combo.liftcmb,f,true))
18489 return qe_invalid;
18490
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftcs,f,true))
18491 return qe_invalid;
18492
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18493 return qe_invalid;
18494
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftundercs,f,true))
18495 return qe_invalid;
18496
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftdmg,f,true))
18497 return qe_invalid;
18498
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftlvl,f,true))
18499 return qe_invalid;
18500
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftitm,f,true))
18501 return qe_invalid;
18502
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftflags,f,true))
18503 return qe_invalid;
18504
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftgfx,f,true))
18505 return qe_invalid;
18506
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftsprite,f,true))
18507 return qe_invalid;
18508
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftsfx,f,true))
18509 return qe_invalid;
18510
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18511 return qe_invalid;
18512
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18513 return qe_invalid;
18514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(s_version >= 34)
18515 {
18516
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.lifthei,f,true))
18517 return qe_invalid;
18518
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_combo.lifttime,f,true))
18519 return qe_invalid;
18520 115 }
18521
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 108 times.
115 if(s_version >= 39)
18522 {
18523
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_getc(&temp_combo.lift_parent_item,f,true))
18524 return qe_invalid;
18525 108 }
18526 115 }
18527
2/2
✓ Branch 0 taken 64973 times.
✓ Branch 1 taken 16 times.
64989 if(combo_has_flags&CHAS_GENERAL)
18528 {
18529
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_combo.speed_mult,f,true))
18530 return qe_invalid;
18531
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_combo.speed_div,f,true))
18532 return qe_invalid;
18533
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetzf(&temp_combo.speed_add,f,true))
18534 return qe_invalid;
18535 16 }
18536 64989 }
18537 185360 update_combo(temp_combo, s_version);
18538 185360 return 0;
18539 185360 }
18540 114 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18541 {
18542 114 word section_version=0;
18543 114 word section_cversion=0;
18544 114 word combos_used=0;
18545 int32_t dummy;
18546 byte padding;
18547 114 newcombo temp_combo;
18548
18549
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 reset_combo_animations();
18550
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 reset_combo_animations2();
18551
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 init_combo_classes();
18552
18553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true) //reset combos
18554 {
18555
2/2
✓ Branch 0 taken 7441920 times.
✓ Branch 1 taken 114 times.
7442034 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18556
1/2
✓ Branch 0 taken 7441920 times.
✗ Branch 1 not taken.
7441920 combobuf[q].clear();
18557 114 }
18558
18559
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(version > 0x192) //Version info
18560 {
18561
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&section_version,f,true))
18562 {
18563 return qe_invalid;
18564 }
18565 110 FFCore.quest_format[vCombos] = section_version;
18566
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&section_cversion,f,true))
18567 {
18568 return qe_invalid;
18569 }
18570
18571 //section size
18572
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetl(&dummy,f,true))
18573 {
18574 return qe_invalid;
18575 }
18576 110 }
18577
18578
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(section_version > 32) //Cleanup time!
18579 {
18580
2/4
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
27 if(!p_igetw(&combos_used,f,true))
18581 {
18582 return qe_invalid;
18583 }
18584
2/2
✓ Branch 0 taken 185360 times.
✓ Branch 1 taken 27 times.
185387 for(int32_t i=0; i<combos_used; i++)
18585 {
18586
1/2
✓ Branch 0 taken 185360 times.
✗ Branch 1 not taken.
185360 auto ret = readcombo_loop(f,section_version,temp_combo);
18587
1/2
✓ Branch 0 taken 185360 times.
✗ Branch 1 not taken.
185360 if(ret) return ret;
18588
2/4
✓ Branch 0 taken 185360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 185360 times.
✗ Branch 3 not taken.
185360 if(keepdata==true && i>=start_combo)
18589
1/2
✓ Branch 0 taken 185360 times.
✗ Branch 1 not taken.
185360 combobuf[i] = temp_combo;
18590 185360 }
18591 27 }
18592 else //Call the old function for all old versions
18593 {
18594
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(ret) return ret; //error, end read
18596 }
18597
18598
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(keepdata==true)
18599 {
18600
3/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 88 times.
114 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18601 {
18602 26 combobuf[0].walk = 0xF0;
18603 26 combobuf[0].type = 0;
18604 26 combobuf[0].flag = 0;
18605 26 }
18606 114 }
18607
18608
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 setup_combo_animations();
18609
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 setup_combo_animations2();
18610 114 return 0;
18611 114 }
18612
18613 105 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18614 {
18615 //these are here to bypass compiler warnings about unused arguments
18616 105 Header=Header;
18617 105 version=version;
18618 105 build=build;
18619
18620 int32_t dummy;
18621 105 word sversion=0, c_sversion;
18622
18623 //section version info
18624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&sversion,f,true))
18625 {
18626 return qe_invalid;
18627 }
18628
18629 105 FFCore.quest_format[vComboAliases] = sversion;
18630
18631 //al_trace("Combo aliases version %d\n", sversion);
18632
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&c_sversion,f,true))
18633 {
18634 return qe_invalid;
18635 }
18636
18637 //section size
18638
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
18639 {
18640 return qe_invalid;
18641 }
18642
18643 105 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18644
18645
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 76 times.
105 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18646 {
18647 76 max_num_combo_aliases = MAX250COMBOALIASES;
18648 76 }
18649
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18650 {
18651 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18652 }
18653
18654
2/2
✓ Branch 0 taken 393216 times.
✓ Branch 1 taken 105 times.
393321 for(int32_t j=0; j<max_num_combo_aliases; j++)
18655 {
18656 byte width,height,mask,tempcset;
18657 int32_t count;
18658 word tempword;
18659 byte tempbyte;
18660
18661
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(!p_igetw(&tempword,f,true))
18662 {
18663 return qe_invalid;
18664 }
18665
18666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 393216 times.
393216 if(keepdata)
18667 {
18668 393216 combo_aliases[j].combo = tempword;
18669 393216 }
18670
18671
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(!p_getc(&tempbyte,f,true))
18672 {
18673 return qe_invalid;
18674 }
18675
18676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 393216 times.
393216 if(keepdata)
18677 {
18678 393216 combo_aliases[j].cset = tempbyte;
18679 393216 }
18680
18681
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(!p_getc(&width,f,true))
18682 {
18683 return qe_invalid;
18684 }
18685
18686
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(!p_getc(&height,f,true))
18687 {
18688 return qe_invalid;
18689 }
18690
18691
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(!p_getc(&mask,f,true))
18692 {
18693 return qe_invalid;
18694 }
18695
18696 393216 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18697
18698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 393216 times.
393216 if(keepdata)
18699 {
18700
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(combo_aliases[j].combos != NULL)
18701 {
18702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 393216 times.
393216 delete[] combo_aliases[j].combos;
18703 393216 }
18704
18705
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(combo_aliases[j].csets != NULL)
18706 {
18707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 393216 times.
393216 delete[] combo_aliases[j].csets;
18708 393216 }
18709
18710 393216 combo_aliases[j].width = width;
18711 393216 combo_aliases[j].height = height;
18712 393216 combo_aliases[j].layermask = mask;
18713 393216 combo_aliases[j].combos = new word[count];
18714 393216 combo_aliases[j].csets = new byte[count];
18715 393216 }
18716
18717
2/2
✓ Branch 0 taken 402693 times.
✓ Branch 1 taken 393216 times.
795909 for(int32_t k=0; k<count; k++)
18718 {
18719
1/2
✓ Branch 0 taken 402693 times.
✗ Branch 1 not taken.
402693 if(!p_igetw(&tempword,f,true))
18720 {
18721 return qe_invalid;
18722 }
18723
18724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402693 times.
402693 if(keepdata)
18725 {
18726 402693 combo_aliases[j].combos[k] = tempword;
18727 402693 }
18728 402693 }
18729
18730
2/2
✓ Branch 0 taken 402693 times.
✓ Branch 1 taken 393216 times.
795909 for(int32_t k=0; k<count; k++)
18731 {
18732
1/2
✓ Branch 0 taken 402693 times.
✗ Branch 1 not taken.
402693 if(!p_getc(&tempcset,f,true))
18733 {
18734 return qe_invalid;
18735 }
18736
18737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402693 times.
402693 if(keepdata)
18738 {
18739 402693 combo_aliases[j].csets[k] = tempcset;
18740 402693 }
18741 402693 }
18742 393216 }
18743
18744 105 word num_combo_pools = 0;
18745
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 27 times.
105 if(sversion >= 4)
18746 {
18747
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_igetw(&num_combo_pools,f,true))
18748 {
18749 return qe_invalid;
18750 }
18751 27 }
18752
18753
2/2
✓ Branch 0 taken 860160 times.
✓ Branch 1 taken 105 times.
860265 for(combo_pool& pool : combo_pools)
18754 {
18755 860160 pool.clear();
18756 }
18757
18758 105 combo_pool temp_cpool;
18759
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 105 times.
177 for(word cp = 0; cp < num_combo_pools; ++cp)
18760 {
18761 72 int32_t num_combos_in_pool = 0;
18762
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 if(!p_igetl(&num_combos_in_pool,f,true))
18763 {
18764 return qe_invalid;
18765 }
18766
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(num_combos_in_pool < 1) continue; //nothing to read
18767
18768
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 temp_cpool.clear();
18769
18770 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18771
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 72 times.
384 for(auto q = 0; q < num_combos_in_pool; ++q)
18772 {
18773
2/4
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
312 if(!p_igetl(&cp_cid,f,true))
18774 {
18775 return qe_invalid;
18776 }
18777
2/4
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
312 if(!p_getc(&cp_cs,f,true))
18778 {
18779 return qe_invalid;
18780 }
18781
2/4
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
312 if(!p_igetw(&cp_quant,f,true))
18782 {
18783 return qe_invalid;
18784 }
18785
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18786 312 }
18787
18788
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(keepdata)
18789 {
18790
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 combo_pools[cp] = temp_cpool;
18791 72 }
18792 72 }
18793
18794 105 return 0;
18795 105 }
18796
18797 114 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18798 {
18799 //these are here to bypass compiler warnings about unused arguments
18800
18801 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18802 //Capitalized cause it'll save you a headache. -Deedee
18803 114 start_cset=start_cset;
18804 114 max_csets=max_csets;
18805 114 word s_version=0;
18806
18807 miscQdata temp_misc;
18808 114 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18809
18810 byte temp_colordata[48];
18811 char temp_palname[PALNAMESIZE];
18812
18813 int32_t dummy;
18814 word palcycles;
18815
18816
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(version > 0x192)
18817 {
18818 //section version info
18819
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
18820 {
18821 return qe_invalid;
18822 }
18823
18824 110 FFCore.quest_format[vCSets] = s_version;
18825
18826 //al_trace("Color data version %d\n", s_version);
18827
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy,f,true))
18828 {
18829 return qe_invalid;
18830 }
18831
18832 //section size
18833
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
18834 {
18835 return qe_invalid;
18836 }
18837 110 }
18838
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
114 if (s_version < 5)
18839 {
18840
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
85 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18841
18842 //finally... section data
18843 85 int32_t q = 0;
18844 85 int32_t p = -15;
18845
2/2
✓ Branch 0 taken 20400 times.
✓ Branch 1 taken 85 times.
20485 for(int32_t i=0; i<oldpdTOTAL; ++i)
18846 {
18847 20400 memset(temp_colordata, 0, 48);
18848
18849
1/2
✓ Branch 0 taken 20400 times.
✗ Branch 1 not taken.
20400 if(!pfread(temp_colordata,48,f,true))
18850 {
18851 return qe_invalid;
18852 }
18853
18854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20400 times.
20400 if(keepdata==true)
18855 {
18856 20400 memcpy(&colordata[q*48], temp_colordata, 48);
18857 20400 }
18858 20400 ++q;
18859
8/8
✓ Branch 0 taken 19040 times.
✓ Branch 1 taken 1360 times.
✓ Branch 2 taken 1445 times.
✓ Branch 3 taken 17595 times.
✓ Branch 4 taken 170 times.
✓ Branch 5 taken 1275 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 162 times.
20400 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18860 {
18861
1/2
✓ Branch 0 taken 1437 times.
✗ Branch 1 not taken.
1437 if (s_version < 5) //Bumping up the size of level palettes
18862 {
18863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1437 times.
1437 if(keepdata==true)
18864 {
18865 1437 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18866 1437 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18867 1437 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18868 1437 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18869 1437 }
18870 1437 q+=4;
18871 1437 }
18872 else
18873 {
18874 for(int m = 0; m < 4; ++m)
18875 {
18876 memset(temp_colordata, 0, 48);
18877 if(!pfread(temp_colordata,48,f,true))
18878 {
18879 return qe_invalid;
18880 }
18881 if(keepdata==true)
18882 {
18883 memcpy(&colordata[q*48], temp_colordata, 48);
18884 }
18885 ++q;
18886 }
18887 }
18888 1437 }
18889 20400 ++p;
18890 20400 }
18891
18892
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 81 times.
85 if(RealOldVerion)
18893 {
18894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
18895 {
18896 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18897 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18898 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18899 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18900 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18901 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18902 4 }
18903 4 }
18904 else
18905 {
18906 81 memset(temp_colordata, 0, 48);
18907
18908
2/2
✓ Branch 0 taken 253773 times.
✓ Branch 1 taken 81 times.
253854 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18909 {
18910
1/2
✓ Branch 0 taken 253773 times.
✗ Branch 1 not taken.
253773 if(!pfread(temp_colordata,48,f,true))
18911 {
18912 return qe_invalid;
18913 }
18914
18915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253773 times.
253773 if(keepdata==true)
18916 {
18917 253773 memcpy(&colordata[q*48], temp_colordata, 48);
18918 253773 }
18919 253773 ++q;
18920
7/8
✓ Branch 0 taken 253773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19521 times.
✓ Branch 3 taken 234252 times.
✓ Branch 4 taken 162 times.
✓ Branch 5 taken 19359 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 10 times.
253773 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18921 {
18922
1/2
✓ Branch 0 taken 19511 times.
✗ Branch 1 not taken.
19511 if (s_version < 5) //Bumping up the size of level palettes
18923 {
18924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19511 times.
19511 if(keepdata==true)
18925 {
18926 19511 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18927 19511 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18928 19511 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18929 19511 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18930 19511 }
18931 19511 q+=4;
18932 19511 }
18933 else
18934 {
18935 for(int m = 0; m < 4; ++m)
18936 {
18937 memset(temp_colordata, 0, 48);
18938 if(!pfread(temp_colordata,48,f,true))
18939 {
18940 return qe_invalid;
18941 }
18942 if(keepdata==true)
18943 {
18944 memcpy(&colordata[q*48], temp_colordata, 48);
18945 }
18946 ++q;
18947 }
18948 }
18949 19511 }
18950 253773 ++p;
18951 253773 }
18952
18953
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 76 times.
81 if(s_version < 4)
18954 {
18955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(keepdata==true)
18956 {
18957 5 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18958 5 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18959 5 }
18960 5 }
18961 else
18962 {
18963
2/2
✓ Branch 0 taken 252928 times.
✓ Branch 1 taken 76 times.
253004 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18964 {
18965
1/2
✓ Branch 0 taken 252928 times.
✗ Branch 1 not taken.
252928 if(!pfread(temp_colordata,48,f,true))
18966 {
18967 return qe_invalid;
18968 }
18969
18970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252928 times.
252928 if(keepdata==true)
18971 {
18972 252928 memcpy(&colordata[q*48], temp_colordata, 48);
18973 252928 }
18974 252928 ++q;
18975
5/6
✓ Branch 0 taken 252928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19456 times.
✓ Branch 3 taken 233472 times.
✓ Branch 4 taken 152 times.
✓ Branch 5 taken 19304 times.
252928 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18976 {
18977
1/2
✓ Branch 0 taken 19304 times.
✗ Branch 1 not taken.
19304 if (s_version < 5) //Bumping up the size of level palettes
18978 {
18979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19304 times.
19304 if(keepdata==true)
18980 {
18981 19304 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18982 19304 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18983 19304 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18984 19304 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18985 19304 }
18986 19304 q+=4;
18987 19304 }
18988 else
18989 {
18990 for(int m = 0; m < 4; ++m)
18991 {
18992 memset(temp_colordata, 0, 48);
18993 if(!pfread(temp_colordata,48,f,true))
18994 {
18995 return qe_invalid;
18996 }
18997 if(keepdata==true)
18998 {
18999 memcpy(&colordata[q*48], temp_colordata, 48);
19000 }
19001 ++q;
19002 }
19003 }
19004 19304 }
19005 252928 ++p;
19006 252928 }
19007
19008 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
19009 }
19010 }
19011 85 }
19012 else
19013 {
19014
2/2
✓ Branch 0 taken 253721 times.
✓ Branch 1 taken 29 times.
253750 for(int32_t i=0; i<pdTOTAL255; ++i)
19015 {
19016 253721 memset(temp_colordata, 0, 48);
19017
19018
1/2
✓ Branch 0 taken 253721 times.
✗ Branch 1 not taken.
253721 if(!pfread(temp_colordata,48,f,true))
19019 {
19020 return qe_invalid;
19021 }
19022
19023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253721 times.
253721 if(keepdata==true)
19024 {
19025 253721 memcpy(&colordata[i*48], temp_colordata, 48);
19026 253721 }
19027 253721 }
19028 }
19029
19030
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((version < 0x192)||((version == 0x192)&&(build<76)))
19031 {
19032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
19033 {
19034 4 init_palnames();
19035 4 }
19036 4 }
19037 else
19038 {
19039 110 int32_t palnamestoread = 0;
19040
19041
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(s_version < 3)
19042 5 palnamestoread = OLDMAXLEVELS;
19043 else
19044 105 palnamestoread = 512;
19045
19046
2/2
✓ Branch 0 taken 55040 times.
✓ Branch 1 taken 110 times.
55150 for(int32_t i=0; i<palnamestoread; ++i)
19047 {
19048 55040 memset(temp_palname, 0, PALNAMESIZE);
19049
19050
1/2
✓ Branch 0 taken 55040 times.
✗ Branch 1 not taken.
55040 if(!pfread(temp_palname,PALNAMESIZE,f,true))
19051 {
19052 return qe_invalid;
19053 }
19054
19055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55040 times.
55040 if(keepdata==true)
19056 {
19057 55040 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19058 55040 }
19059 55040 }
19060
19061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(keepdata)
19062 {
19063
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 110 times.
1390 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19064 {
19065 1280 memset(palnames[i], 0, PALNAMESIZE);
19066 1280 }
19067 110 }
19068 }
19069
19070
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(version > 0x192)
19071 {
19072
2/2
✓ Branch 0 taken 28160 times.
✓ Branch 1 taken 110 times.
28270 for(int32_t i=0; i<256; i++)
19073 {
19074
2/2
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 28160 times.
112640 for(int32_t j=0; j<3; j++)
19075 {
19076 84480 temp_misc.cycles[i][j].first=0;
19077 84480 temp_misc.cycles[i][j].count=0;
19078 84480 temp_misc.cycles[i][j].speed=0;
19079 84480 }
19080 28160 }
19081
19082
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&palcycles,f,true))
19083 {
19084 return qe_invalid;
19085 }
19086
19087
2/2
✓ Branch 0 taken 3448 times.
✓ Branch 1 taken 110 times.
3558 for(int32_t i=0; i<palcycles; i++)
19088 {
19089
2/2
✓ Branch 0 taken 10344 times.
✓ Branch 1 taken 3448 times.
13792 for(int32_t j=0; j<3; j++)
19090 {
19091
1/2
✓ Branch 0 taken 10344 times.
✗ Branch 1 not taken.
10344 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
19092 {
19093 return qe_invalid;
19094 }
19095 10344 }
19096
19097
2/2
✓ Branch 0 taken 10344 times.
✓ Branch 1 taken 3448 times.
13792 for(int32_t j=0; j<3; j++)
19098 {
19099
1/2
✓ Branch 0 taken 10344 times.
✗ Branch 1 not taken.
10344 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
19100 {
19101 return qe_invalid;
19102 }
19103 10344 }
19104
19105
2/2
✓ Branch 0 taken 10344 times.
✓ Branch 1 taken 3448 times.
13792 for(int32_t j=0; j<3; j++)
19106 {
19107
1/2
✓ Branch 0 taken 10344 times.
✗ Branch 1 not taken.
10344 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
19108 {
19109 return qe_invalid;
19110 }
19111 10344 }
19112 3448 }
19113
19114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(keepdata==true)
19115 {
19116 110 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19117 110 }
19118 110 }
19119
19120 114 return 0;
19121 114 }
19122
19123 114 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
19124 {
19125 114 int32_t tiles_used=0;
19126 114 word section_version = 0;
19127 114 word section_cversion = 0;
19128 114 int32_t section_size= 0;
19129 114 byte *temp_tile = new byte[tilesize(tf32Bit)];
19130
19131 //Tile Expansion
19132 //if ( version >= 0x254 && build >= 41 )
19133
3/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 85 times.
114 if (version < 0x254 && build < 41)
19134 {
19135 //al_trace("Build was < 41 when reading tiles\n");
19136 85 max_tiles = ZC250MAXTILES;
19137 85 }
19138
19139 //al_trace("Max Tiles: %d\n", max_tiles);
19140
19141
2/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19142 {
19143 if(keepdata==true)
19144 {
19145 if(!init_tiles(true, Header))
19146 {
19147 al_trace("Unable to initialize tiles\n");
19148 }
19149 }
19150
19151 delete[] temp_tile;
19152 temp_tile=NULL;
19153 return 0;
19154 }
19155 else
19156 {
19157
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(version > 0x192)
19158 {
19159 //section version info
19160
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&section_version,f,true))
19161 {
19162 delete[] temp_tile;
19163 return qe_invalid;
19164 }
19165
19166 110 FFCore.quest_format[vTiles] = section_version;
19167
19168
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&section_cversion,f,true))
19169 {
19170 delete[] temp_tile;
19171 return qe_invalid;
19172 }
19173
19174 //section size
19175
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&section_size,f,true))
19176 {
19177 delete[] temp_tile;
19178 return qe_invalid;
19179 }
19180 110 }
19181
19182 //if ( build < 41 )
19183 //{
19184 // tiles_used = ZC250MAXTILES;
19185 //}
19186
19187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(version < 0x174)
19188 {
19189 tiles_used=TILES_PER_PAGE*4;
19190 } //no expanded tile space
19191
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 else if(version < 0x191)
19192 {
19193 4 tiles_used=OLDMAXTILES;
19194 4 }
19195 else
19196 {
19197 //finally... section data
19198
3/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
110 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19199 {
19200
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetl(&tiles_used,f,true))
19201 {
19202 delete[] temp_tile;
19203 return qe_invalid;
19204 }
19205 29 }
19206 else
19207 {
19208
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_igetw(&tiles_used,f,true))
19209 {
19210 delete[] temp_tile;
19211 return qe_invalid;
19212 }
19213 }
19214 }
19215
19216
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 tiles_used=zc_min(tiles_used, max_tiles);
19217
19218 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19219 //if ( version < 0x254 && build < 41 )
19220
3/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if ( version < 0x254 || (version == 0x254 && build < 41) )
19221 //if ( build < 41 )
19222 {
19223
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19224 85 }
19225 else //2.55
19226 {
19227
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19228 }
19229
19230 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19231
19232 //al_trace("tiles_used = %d\n", tiles_used);
19233
19234
2/2
✓ Branch 0 taken 2707919 times.
✓ Branch 1 taken 114 times.
2708033 for(int32_t i=0; i<tiles_used; ++i)
19235 {
19236 2707919 byte format=tf4Bit;
19237 2707919 memset(temp_tile, 0, tilesize(tf32Bit));
19238
19239
3/6
✓ Branch 0 taken 172238 times.
✓ Branch 1 taken 2535681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 172238 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2707919 if((version>0x211)||((version==0x211)&&(build>4)))
19240 {
19241
1/2
✓ Branch 0 taken 2535681 times.
✗ Branch 1 not taken.
2535681 if(!p_getc(&format,f,true))
19242 {
19243 delete[] temp_tile;
19244 return qe_invalid;
19245 }
19246 2535681 }
19247
4/4
✓ Branch 0 taken 995916 times.
✓ Branch 1 taken 1712003 times.
✓ Branch 2 taken 490725 times.
✓ Branch 3 taken 505191 times.
2707919 if(section_version > 2 && !format)
19248 {
19249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 505191 times.
505191 if(keepdata)
19250 {
19251 505191 reset_tile(buf,start_tile+i,tf4Bit);
19252 505191 }
19253 505191 continue;
19254 }
19255
19256
1/2
✓ Branch 0 taken 2202728 times.
✗ Branch 1 not taken.
2202728 if(!pfread(temp_tile,tilesize(format),f,true))
19257 {
19258 delete[] temp_tile;
19259 return qe_invalid;
19260 }
19261
19262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2202728 times.
2202728 if(keepdata==true)
19263 {
19264 2202728 buf[start_tile+i].format=format;
19265
19266
1/2
✓ Branch 0 taken 2202728 times.
✗ Branch 1 not taken.
2202728 if(buf[start_tile+i].data)
19267 {
19268 2202728 free(buf[start_tile+i].data);
19269 2202728 buf[start_tile+i].data=NULL;
19270 2202728 }
19271
19272 2202728 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19273 2202728 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19274 2202728 }
19275 2202728 }
19276 }
19277
19278
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19279 {
19280 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19281
2/2
✓ Branch 0 taken 12663300 times.
✓ Branch 1 taken 85 times.
12663385 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19282 {
19283
19284 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19285 12663300 reset_tile(buf,q,tf4Bit);
19286
19287
19288 /*
19289
19290 byte tempbyte;
19291 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19292 {
19293 tempbyte=buf[ZC250MAXTILES-1].data[i];
19294 buf[q].data[i] = tempbyte;
19295 }
19296 //int32_t temp = tempbyte=buf[130].data[i];
19297 //buf[q].data = buf[ZC250MAXTILES-1].data;
19298 */
19299 //reset_tile(buf,q,tf4Bit);
19300 12663300 }
19301
19302 85 }
19303
19304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
19305 {
19306
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
114 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19307 {
19308
2/2
✓ Branch 0 taken 4065817 times.
✓ Branch 1 taken 85 times.
4065902 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19309 {
19310 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19311 4065817 reset_tile(buf,i,tf4Bit);
19312 4065817 }
19313 85 }
19314 else
19315 {
19316
2/2
✓ Branch 0 taken 5015964 times.
✓ Branch 1 taken 29 times.
5015993 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19317 {
19318 //al_trace("Resetting tiles for build 41+\n");
19319 5015964 reset_tile(buf,i,tf4Bit);
19320 5015964 }
19321 }
19322
19323
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19324 {
19325
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(quest_rules,qr_BSZELDA)) //
19326 {
19327 byte tempbyte;
19328 int32_t floattile=wpnsbuf[iwSwim].tile;
19329
19330 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19331 {
19332 tempbyte=buf[23].data[i];
19333 buf[23].data[i]=buf[24].data[i];
19334 buf[24].data[i]=buf[25].data[i];
19335 buf[25].data[i]=buf[26].data[i];
19336 buf[26].data[i]=tempbyte;
19337 }
19338 //swim tiles are out of order, too, but nobody cared? -Z
19339 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19340 {
19341 tempbyte=buf[floattile+11].data[i];
19342 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19343 buf[floattile+12].data[i]=tempbyte;
19344 }
19345 }
19346 4 }
19347
19348
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19349 {
19350
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19351 {
19352 byte tempbyte;
19353
19354
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19355 {
19356 512 tempbyte=buf[130].data[i];
19357 512 buf[130].data[i]=buf[132].data[i];
19358 512 buf[132].data[i]=tempbyte;
19359
19360 512 tempbyte=buf[131].data[i];
19361 512 buf[131].data[i]=buf[133].data[i];
19362 512 buf[133].data[i]=tempbyte;
19363 512 }
19364 4 }
19365 9 }
19366
19367 114 al_trace("Registering blank tiles\n");
19368 114 register_blank_tiles();
19369 114 }
19370
19371 //memset(temp_tile, 0, tilesize(tf32Bit));
19372
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 delete[] temp_tile;
19373 114 temp_tile=NULL;
19374 114 return 0;
19375 114 }
19376
19377 114 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19378 {
19379 114 byte *mf=midi_flags;
19380 int32_t dummy;
19381 word dummy2;
19382 // zcmidi_ temp_midi;
19383 int32_t tunes_to_read;
19384 114 int32_t tune_count=0;
19385 114 word section_version=0;
19386 114 zctune temp;
19387
19388
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version < 0x193)
19389 {
19390 // mf=Header->data_flags+ZQ_MIDIS2;
19391
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19392 {
19393 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19394 4 }
19395 else
19396 {
19397 tunes_to_read=MAXCUSTOMTUNES;
19398 }
19399 4 }
19400 else
19401 {
19402 //section version info
19403
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&section_version,f,true))
19404 {
19405 return qe_invalid;
19406 }
19407
19408 110 FFCore.quest_format[vMIDIs] = section_version;
19409
19410 //al_trace("Tunes version %d\n", section_version);
19411
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy2,f,true))
19412 {
19413 return qe_invalid;
19414 }
19415
19416 //section size
19417
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
19418 {
19419 return qe_invalid;
19420 }
19421
19422 //finally... section data
19423
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19424 {
19425 return qe_invalid;
19426 }
19427
19428 110 tunes_to_read=MAXCUSTOMTUNES;
19429 }
19430
19431
2/2
✓ Branch 0 taken 28728 times.
✓ Branch 1 taken 114 times.
28842 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19432 {
19433
2/2
✓ Branch 0 taken 26853 times.
✓ Branch 1 taken 1875 times.
28728 if(get_bit(mf, i))
19434 {
19435 1875 ++tune_count;
19436 1875 }
19437 28728 }
19438
19439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
19440 {
19441 114 reset_tunes(tunes); //reset_midis(midis);
19442 114 }
19443
19444
2/2
✓ Branch 0 taken 27848 times.
✓ Branch 1 taken 114 times.
27962 for(int32_t i=0; i<tunes_to_read; i++)
19445 {
19446 27848 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19447
19448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27848 times.
27848 if(keepdata==true)
19449 {
19450 27848 tunes[i].reset(); // reset_midi(midis+i);
19451 27848 }
19452
19453
2/2
✓ Branch 0 taken 25973 times.
✓ Branch 1 taken 1875 times.
27848 if(get_bit(mf,i))
19454 {
19455
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1578 times.
1875 if(section_version < 4)
19456 {
19457
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19458 {
19459 return qe_invalid;
19460 }
19461 297 }
19462 else
19463 {
19464
1/2
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
1578 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19465 {
19466 return qe_invalid;
19467 }
19468 }
19469
19470
1/2
✓ Branch 0 taken 1875 times.
✗ Branch 1 not taken.
1875 if(!p_igetl(&temp.start,f,true))
19471 {
19472 return qe_invalid;
19473 }
19474
19475
1/2
✓ Branch 0 taken 1875 times.
✗ Branch 1 not taken.
1875 if(!p_igetl(&temp.loop_start,f,true))
19476 {
19477 return qe_invalid;
19478 }
19479
19480
1/2
✓ Branch 0 taken 1875 times.
✗ Branch 1 not taken.
1875 if(!p_igetl(&temp.loop_end,f,true))
19481 {
19482 return qe_invalid;
19483 }
19484
19485
1/2
✓ Branch 0 taken 1875 times.
✗ Branch 1 not taken.
1875 if(!p_igetw(&temp.loop,f,true))
19486 {
19487 return qe_invalid;
19488 }
19489
19490
1/2
✓ Branch 0 taken 1875 times.
✗ Branch 1 not taken.
1875 if(!p_igetw(&temp.volume,f,true))
19491 {
19492 return qe_invalid;
19493 }
19494
19495
2/2
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 78 times.
1875 if(Header->zelda_version < 0x193)
19496 {
19497
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f,true))
19498 {
19499 return qe_invalid;
19500 }
19501 78 }
19502
19503
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1578 times.
1875 if(section_version >= 3)
19504 {
19505
1/2
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
1578 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19506 {
19507 return qe_invalid;
19508 }
19509 1578 }
19510
19511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1875 times.
1875 if(keepdata==true)
19512 {
19513 1875 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19514 1875 }
19515
19516
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1578 times.
1875 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19517 {
19518 // old format - a midi is a midi
19519
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19520 {
19521 return qe_invalid;
19522 }
19523
19524 //yes you can do this. Isn't the ? operator awesome? :)
19525
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19526 297 }
19527 else
19528 {
19529 // 'midi' could be midi or nes, gb, ... music
19530
2/4
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1578 times.
✗ Branch 3 not taken.
1578 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19531 {
19532 return qe_invalid;
19533 }
19534
19535
1/2
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
1578 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19536
19537
1/2
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
1578 switch(temp.format)
19538 {
19539 case MFORMAT_MIDI:
19540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1578 times.
1578 if((ptr->data=read_midi(f, true))==NULL)
19541 {
19542 return qe_invalid;
19543 }
19544
19545 1578 break;
19546
19547 default:
19548 return qe_invalid;
19549 break;
19550 }
19551 }
19552 1875 }
19553 27848 }
19554
19555 114 return 0;
19556 114 }
19557
19558 114 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19559 {
19560 int32_t dummy;
19561 ZCHEATS tempzcheats;
19562 114 char temp_use_cheats=1;
19563 114 memset(&tempzcheats, 0, sizeof(tempzcheats));
19564 114 word s_version = 0;
19565
19566
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if(Header->zelda_version > 0x192)
19567 {
19568 //section version info
19569
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&s_version,f,true))
19570 {
19571 return qe_invalid;
19572 }
19573
19574 110 FFCore.quest_format[vCheats] = s_version;
19575 //al_trace("Cheats version %d\n", dummy);
19576
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetw(&dummy,f,true))
19577 {
19578 return qe_invalid;
19579 }
19580
19581 //section size
19582
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_igetl(&dummy,f,true))
19583 {
19584 return qe_invalid;
19585 }
19586
19587 //finally... section data
19588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(!p_getc(&temp_use_cheats,f,true))
19589 {
19590 return qe_invalid;
19591 }
19592 110 }
19593
19594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(Header->data_flags[ZQ_CHEATS2])
19595 {
19596
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&tempzcheats.flags,f,true))
19597 {
19598 return qe_invalid;
19599 }
19600
19601
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19602 {
19603 return qe_invalid;
19604 }
19605 114 }
19606
19607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(keepdata==true)
19608 {
19609 114 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19610 114 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19611 114 }
19612
19613 114 return 0;
19614 114 }
19615
19616 276 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19617 {
19618 int32_t dummy;
19619 276 word s_version=0, s_cversion=0;
19620 byte padding;
19621 word tempw;
19622
19623 276 zinitdata temp_zinit;
19624
19625 // Legacy item properties (now integrated into itemdata)
19626 byte sword_hearts[4];
19627 byte beam_hearts[4];
19628 276 byte beam_percent=0;
19629 word beam_power[4];
19630 276 byte hookshot_length=99;
19631 276 byte hookshot_links=100;
19632 276 byte longshot_length=99;
19633 276 byte longshot_links=100;
19634 276 byte moving_fairy_hearts=3;
19635 276 byte moving_fairy_heart_percent=0;
19636 276 byte stationary_fairy_hearts=3;
19637 276 byte stationary_fairy_heart_percent=0;
19638 276 byte moving_fairy_magic=0;
19639 276 byte moving_fairy_magic_percent=0;
19640 276 byte stationary_fairy_magic=0;
19641 276 byte stationary_fairy_magic_percent=0;
19642 276 byte blue_potion_hearts=100;
19643 276 byte blue_potion_heart_percent=1;
19644 276 byte red_potion_hearts=100;
19645 276 byte red_potion_heart_percent=1;
19646 276 byte blue_potion_magic=100;
19647 276 byte blue_potion_magic_percent=1;
19648 276 byte red_potion_magic=100;
19649 276 byte red_potion_magic_percent=1;
19650
19651
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 162 times.
276 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19652
19653
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(Header->zelda_version > 0x192)
19654 {
19655 //section version info
19656
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&s_version,f,true))
19657 {
19658 return qe_invalid;
19659 }
19660
19661 110 FFCore.quest_format[vInitData] = s_version;
19662
19663 //al_trace("Init data version %d\n", s_version);
19664
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&s_cversion,f,true))
19665 {
19666 return qe_invalid;
19667 }
19668
19669 //section size
19670
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetl(&dummy,f,true))
19671 {
19672 return qe_invalid;
19673 }
19674 110 }
19675
19676 /* HIGHLY UNORTHODOX UPDATING THING, by L
19677 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19678 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19679 * changing from 13 to 14.
19680 */
19681
3/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 9 times.
114 if(keepdata && s_version < 14)
19682 9 fixpolsvoice=true;
19683
19684 /* End highly unorthodox updating thing */
19685
19686
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 31 times.
114 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19687 31 temp_zinit.jump_hero_layer_threshold=0;
19688
19689
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
114 if(s_version >= 10)
19690 {
19691 char temp;
19692
19693 //new-style items
19694
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t j=0; j<256; j++)
19695 {
19696
2/4
✓ Branch 0 taken 26880 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26880 times.
26880 if(!p_getc(&temp,f,true))
19697 return qe_invalid;
19698
19699 26880 temp_zinit.items[j] = (temp != 0);
19700 26880 }
19701 105 }
19702
19703
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 52 times.
114 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19704 {
19705 char temp;
19706
19707 //finally... section data
19708
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 52 times.
162 if((Header->zelda_version > 0x192)||
19709 //new only
19710 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19711 {
19712 //OLD-style items... sigh
19713
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(s_version < 10)
19714 {
19715
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19716 {
19717 return qe_invalid;
19718 }
19719
19720 5 temp_zinit.items[iRaft]=(temp != 0);
19721
19722
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19723 {
19724 return qe_invalid;
19725 }
19726
19727 5 temp_zinit.items[iLadder]=(temp != 0);
19728
19729
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19730 {
19731 return qe_invalid;
19732 }
19733
19734 5 temp_zinit.items[iBook]=(temp != 0);
19735
19736
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19737 {
19738 return qe_invalid;
19739 }
19740
19741 5 temp_zinit.items[iMKey]=(temp!=0);
19742
19743
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19744 {
19745 return qe_invalid;
19746 }
19747
19748 5 temp_zinit.items[iFlippers]=(temp != 0);
19749
19750
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19751 {
19752 return qe_invalid;
19753 }
19754
19755 5 temp_zinit.items[iBoots]=(temp!=0);
19756 5 }
19757 110 }
19758
19759
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 157 times.
162 if(s_version < 10)
19760 {
19761 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19762
19763
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempring,f,true))
19764 {
19765 return qe_invalid;
19766 }
19767
19768
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempsword,f,true))
19769 {
19770 return qe_invalid;
19771 }
19772
19773
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempshield,f,true))
19774 {
19775 return qe_invalid;
19776 }
19777
19778
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwallet,f,true))
19779 {
19780 return qe_invalid;
19781 }
19782
19783
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbracelet,f,true))
19784 {
19785 return qe_invalid;
19786 }
19787
19788
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempamulet,f,true))
19789 {
19790 return qe_invalid;
19791 }
19792
19793
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbow,f,true))
19794 {
19795 return qe_invalid;
19796 }
19797
19798 //old only
19799
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19800 {
19801 tempring=(tempring)?(1<<(tempring-1)):0;
19802 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19803 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19804 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19805 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19806 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19807 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19808 }
19809
19810 //rings start at level 2... wtf
19811 //account for this -DD
19812 5 tempring <<= 1;
19813
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19814
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19815
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19816
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19817 //bracelet ALSO starts at level 2 :-( -DD
19818 5 tempbracelet<<=1;
19819
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19820
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19821
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19822
19823 //new only
19824
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
19825 {
19826 for(int32_t q=0; q<32; q++)
19827 {
19828 if(!p_getc(&padding,f,true))
19829 {
19830 return qe_invalid;
19831 }
19832 }
19833 }
19834
19835 char tempcandle, tempboomerang, temparrow, tempwhistle;
19836
19837
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempcandle,f,true))
19838 {
19839 return qe_invalid;
19840 }
19841
19842
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempboomerang,f,true))
19843 {
19844 return qe_invalid;
19845 }
19846
19847
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temparrow,f,true))
19848 {
19849 return qe_invalid;
19850 }
19851
19852
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19853 {
19854 return qe_invalid;
19855 }
19856
19857
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19858
19859
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwhistle,f,true))
19860 {
19861 return qe_invalid;
19862 }
19863
19864 //old only
19865
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19866 {
19867 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19868 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19869 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19870 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19871 }
19872
19873
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19874
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19875
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19876
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19877 //What about the potion...?
19878
19879 5 }
19880
19881
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 81 times.
162 if(s_version < 29)
19882 {
19883 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19884 //to jab out my eye...
19885
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
81 if(!p_getc(&padding,f,true))
19886 return qe_invalid;
19887 81 temp_zinit.bombs = padding;
19888
19889
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
81 if(!p_getc(&padding,f,true))
19890 return qe_invalid;
19891 81 temp_zinit.super_bombs = padding;
19892 81 }
19893
19894 //Back to more OLD item code
19895
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
162 if(s_version < 10)
19896 {
19897
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version > 0x192)||
19898 //new only
19899 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19900 {
19901
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19902 {
19903 return qe_invalid;
19904 }
19905
19906
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19907
19908
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19909 {
19910 return qe_invalid;
19911 }
19912
19913
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19914
19915
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19916 {
19917 return qe_invalid;
19918 }
19919
19920
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19921
19922
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19923 {
19924 return qe_invalid;
19925 }
19926
19927
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19928
19929
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19930 {
19931 return qe_invalid;
19932 }
19933
19934
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19935
19936
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19937 {
19938 return qe_invalid;
19939 }
19940
19941
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19942
19943
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19944 {
19945 return qe_invalid;
19946 }
19947
19948
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19949
19950
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19951 {
19952 return qe_invalid;
19953 }
19954
19955
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19956
19957
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19958 {
19959 return qe_invalid;
19960 }
19961
19962
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19963
19964
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19965 {
19966 return qe_invalid;
19967 }
19968
19969
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(Header->zelda_version == 0x192)
19970 {
19971 for(int32_t q=0; q<32; q++)
19972 {
19973 if(!p_getc(&padding,f,true))
19974 {
19975 return qe_invalid;
19976 }
19977 }
19978 }
19979 5 }
19980 5 }
19981
19982 //old only
19983
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
10 if((Header->zelda_version == 0x192)&&(Header->build<174))
19984 {
19985 byte equipment, items; //bit flags
19986
19987 if(!p_getc(&equipment,f,true))
19988 {
19989 return qe_invalid;
19990 }
19991
19992 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19993 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19994 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19995 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19996 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19997 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19998
19999
20000 if(!p_getc(&items,f,true))
20001 {
20002 return qe_invalid;
20003 }
20004
20005 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
20006 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
20007 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
20008 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
20009 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
20010 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
20011 }
20012
20013 if(!p_getc(&temp_zinit.hc,f,true))
20014 {
20015 return qe_invalid;
20016 }
20017
20018
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(s_version < 14)
20019 {
20020 byte temphp;
20021
20022
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
20023 {
20024 return qe_invalid;
20025 }
20026
20027 5 temp_zinit.start_heart=temphp;
20028
20029
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
20030 {
20031 return qe_invalid;
20032 }
20033
20034 5 temp_zinit.cont_heart=temphp;
20035 5 }
20036 else
20037 {
20038
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.start_heart,f,true))
20039 {
20040 return qe_invalid;
20041 }
20042
20043
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.cont_heart,f,true))
20044 {
20045 return qe_invalid;
20046 }
20047 }
20048
20049
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.hcp,f,true))
20050 {
20051 return qe_invalid;
20052 }
20053
20054
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version >= 14)
20055 {
20056
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
20057 {
20058 return qe_invalid;
20059 }
20060
20061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version<16) // July 2007
20062 {
20063 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
20064 temp_zinit.hcp_per_hc = 0xFF;
20065
20066 //Dispose of legacy rule
20067 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
20068 }
20069 105 }
20070
20071
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 29 times.
110 if(s_version < 29)
20072 {
20073
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
81 if(!p_getc(&padding,f,true))
20074 return qe_invalid;
20075 81 temp_zinit.max_bombs = padding;
20076 81 }
20077
20078
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.keys,f,true))
20079 {
20080 return qe_invalid;
20081 }
20082
20083
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_igetw(&temp_zinit.rupies,f,true))
20084 {
20085 return qe_invalid;
20086 }
20087
20088
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.triforce,f,true))
20089 {
20090 return qe_invalid;
20091 }
20092
20093
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
110 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20094 {
20095
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 105 times.
6825 for(int32_t i=0; i<64; i++)
20096 {
20097
2/4
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6720 times.
6720 if(!p_getc(&temp_zinit.map[i],f,true))
20098 {
20099 return qe_invalid;
20100 }
20101 6720 }
20102
20103
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 105 times.
6825 for(int32_t i=0; i<64; i++)
20104 {
20105
2/4
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6720 times.
6720 if(!p_getc(&temp_zinit.compass[i],f,true))
20106 {
20107 return qe_invalid;
20108 }
20109 6720 }
20110 105 }
20111 else
20112 {
20113
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20114 {
20115
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.map[i],f,true))
20116 {
20117 return qe_invalid;
20118 }
20119 160 }
20120
20121
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20122 {
20123
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.compass[i],f,true))
20124 {
20125 return qe_invalid;
20126 }
20127 160 }
20128 }
20129
20130
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110 if((Header->zelda_version > 0x192)||
20131 //new only
20132 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20133 {
20134
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
110 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20135 {
20136
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 105 times.
6825 for(int32_t i=0; i<64; i++)
20137 {
20138
2/4
✓ Branch 0 taken 6720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6720 times.
6720 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20139 {
20140 return qe_invalid;
20141 }
20142 6720 }
20143 105 }
20144 else
20145 {
20146
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20147 {
20148
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20149 {
20150 return qe_invalid;
20151 }
20152 160 }
20153 }
20154 110 }
20155
20156
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 1760 times.
1870 for(int32_t i=0; i<16; i++)
20157 {
20158
2/4
✓ Branch 0 taken 1760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1760 times.
1760 if(!p_getc(&temp_zinit.misc[i],f,true))
20159 {
20160 return qe_invalid;
20161 }
20162 1760 }
20163
20164
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 5 times.
130 if(s_version < 15) for(int32_t i=0; i<4; i++)
20165 {
20166
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&sword_hearts[i],f,true))
20167 {
20168 return qe_invalid;
20169 }
20170 25 }
20171
20172
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.last_map,f,true))
20173 {
20174 return qe_invalid;
20175 }
20176
20177
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.last_screen,f,true))
20178 {
20179 return qe_invalid;
20180 }
20181
20182
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(s_version < 14)
20183 {
20184 byte tempmp;
20185
20186
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
20187 {
20188 return qe_invalid;
20189 }
20190
20191 5 temp_zinit.max_magic=tempmp;
20192
20193
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
20194 {
20195 return qe_invalid;
20196 }
20197
20198 5 temp_zinit.magic=tempmp;
20199 5 }
20200 else
20201 {
20202
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.max_magic,f,true))
20203 {
20204 return qe_invalid;
20205 }
20206
20207
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.magic,f,true))
20208 {
20209 return qe_invalid;
20210 }
20211 }
20212
20213
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version < 15)
20214 {
20215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version < 12)
20216 {
20217 5 temp_zinit.max_magic*=32;
20218 5 temp_zinit.magic*=32;
20219 5 }
20220
20221
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20222 {
20223
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&beam_hearts[i],f,true))
20224 {
20225 return qe_invalid;
20226 }
20227 20 }
20228
20229
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&beam_percent,f,true))
20230 {
20231 return qe_invalid;
20232 }
20233 5 }
20234 else
20235 {
20236
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20237 {
20238 return qe_invalid;
20239 }
20240 }
20241
20242
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version < 15)
20243 {
20244 byte tempbp;
20245
20246
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20247 {
20248
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
20 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20249 {
20250 return qe_invalid;
20251 }
20252
20253 20 beam_power[i]=tempbp;
20254 20 }
20255
20256
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&hookshot_links,f,true))
20257 {
20258 return qe_invalid;
20259 }
20260
20261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version>6)
20262 {
20263 if(!p_getc(&hookshot_length,f,true))
20264 {
20265 return qe_invalid;
20266 }
20267
20268 if(!p_getc(&longshot_links,f,true))
20269 {
20270 return qe_invalid;
20271 }
20272
20273 if(!p_getc(&longshot_length,f,true))
20274 {
20275 return qe_invalid;
20276 }
20277 }
20278 5 }
20279
20280
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20281 {
20282 return qe_invalid;
20283 }
20284
20285
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20286 {
20287 return qe_invalid;
20288 }
20289
20290
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.subscreen,f,true))
20291 {
20292 return qe_invalid;
20293 }
20294
20295 //old only
20296
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110 if((Header->zelda_version == 0x192)&&(Header->build<174))
20297 {
20298 for(int32_t i=0; i<32; i++)
20299 {
20300 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20301 {
20302 return qe_invalid;
20303 }
20304 }
20305 }
20306
20307
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
110 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20308 {
20309
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(s_version <= 10)
20310 {
20311 byte tempbyte;
20312
20313
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbyte,f,true))
20314 {
20315 return qe_invalid;
20316 }
20317
20318 5 temp_zinit.start_dmap = (word)tempbyte;
20319 5 }
20320 else
20321 {
20322
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20323 {
20324 return qe_invalid;
20325 }
20326 }
20327
20328
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
110 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20329 {
20330 return qe_invalid;
20331 }
20332 110 }
20333
20334
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 29 times.
110 if(s_version>1 && s_version < 29)
20335 {
20336
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if(!p_getc(&padding,f,true))
20337 return qe_invalid;
20338 76 temp_zinit.arrows = padding;
20339
20340
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if(!p_getc(&padding,f,true))
20341 return qe_invalid;
20342 76 temp_zinit.max_arrows = padding;
20343 76 }
20344
20345
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 105 times.
110 if(s_version>2)
20346 {
20347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(s_version <= 10)
20348 {
20349 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20350 {
20351 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20352 {
20353 return qe_invalid;
20354 }
20355 }
20356 }
20357 else
20358 {
20359
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 105 times.
53865 for(int32_t i=0; i<MAXLEVELS; i++)
20360 {
20361
2/4
✓ Branch 0 taken 53760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✗ Branch 3 not taken.
53760 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20362 {
20363 return qe_invalid;
20364 }
20365 53760 }
20366 }
20367 105 }
20368
20369
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version>3)
20370 {
20371
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20372 {
20373 return qe_invalid;
20374 }
20375
20376
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20377 {
20378 return qe_invalid;
20379 }
20380
20381
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20382 {
20383 return qe_invalid;
20384 }
20385
20386
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20387 {
20388 return qe_invalid;
20389 }
20390
20391
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20392 {
20393 return qe_invalid;
20394 }
20395
20396
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20397 {
20398 return qe_invalid;
20399 }
20400
20401
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20402 {
20403 return qe_invalid;
20404 }
20405
20406
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20407 {
20408 return qe_invalid;
20409 }
20410
20411
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20412
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20413 105 }
20414
20415
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
110 if(s_version>4 && s_version<15)
20416 {
20417 if(!p_getc(&moving_fairy_hearts,f,true))
20418 {
20419 return qe_invalid;
20420 }
20421
20422 if(!p_getc(&moving_fairy_heart_percent,f,true))
20423 {
20424 return qe_invalid;
20425 }
20426 }
20427
20428
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
110 if(s_version>5 && s_version < 10)
20429 {
20430 if(!p_getc(&temp,f,true))
20431 {
20432 return qe_invalid;
20433 }
20434
20435 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20436 }
20437
20438
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
110 if(s_version>6 && s_version<15)
20439 {
20440 if(!p_getc(&stationary_fairy_hearts,f,true))
20441 {
20442 return qe_invalid;
20443 }
20444
20445 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20446 {
20447 return qe_invalid;
20448 }
20449
20450 if(!p_getc(&moving_fairy_magic,f,true))
20451 {
20452 return qe_invalid;
20453 }
20454
20455 if(!p_getc(&moving_fairy_magic_percent,f,true))
20456 {
20457 return qe_invalid;
20458 }
20459
20460 if(!p_getc(&stationary_fairy_magic,f,true))
20461 {
20462 return qe_invalid;
20463 }
20464
20465 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20466 {
20467 return qe_invalid;
20468 }
20469
20470 if(!p_getc(&blue_potion_hearts,f,true))
20471 {
20472 return qe_invalid;
20473 }
20474
20475 if(!p_getc(&blue_potion_heart_percent,f,true))
20476 {
20477 return qe_invalid;
20478 }
20479
20480 if(!p_getc(&red_potion_hearts,f,true))
20481 {
20482 return qe_invalid;
20483 }
20484
20485 if(!p_getc(&red_potion_heart_percent,f,true))
20486 {
20487 return qe_invalid;
20488 }
20489
20490 if(!p_getc(&blue_potion_magic,f,true))
20491 {
20492 return qe_invalid;
20493 }
20494
20495 if(!p_getc(&blue_potion_magic_percent,f,true))
20496 {
20497 return qe_invalid;
20498 }
20499
20500 if(!p_getc(&red_potion_magic,f,true))
20501 {
20502 return qe_invalid;
20503 }
20504
20505 if(!p_getc(&red_potion_magic_percent,f,true))
20506 {
20507 return qe_invalid;
20508 }
20509 }
20510
20511
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version>6)
20512 {
20513
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20514 {
20515 return qe_invalid;
20516 }
20517 105 }
20518
20519
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version>7)
20520 {
20521
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20522 {
20523 return qe_invalid;
20524 }
20525 105 }
20526
20527
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version>8)
20528 {
20529
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20530 {
20531 return qe_invalid;
20532 }
20533
20534
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.max_keys,f,true))
20535 {
20536 return qe_invalid;
20537 }
20538 105 }
20539
20540
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version>16)
20541 {
20542
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.gravity,f,true))
20543 {
20544 return qe_invalid;
20545 }
20546
20547
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.terminalv,f,true))
20548 {
20549 return qe_invalid;
20550 }
20551
20552
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.msg_speed,f,true))
20553 {
20554 return qe_invalid;
20555 }
20556
20557
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.transition_type,f,true))
20558 {
20559 return qe_invalid;
20560 }
20561
20562
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20563 {
20564 return qe_invalid;
20565 }
20566 105 }
20567
4/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
5 else if(replay_is_replaying() && replay_get_version() < 13)
20568 5 temp_zinit.msg_speed = 0;
20569
20570
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(s_version>17)
20571 {
20572
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20573 {
20574 return qe_invalid;
20575 }
20576 105 }
20577
20578 //expaned init data for larger values in 2.55
20579
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20580 {
20581
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.bombs,f,true))
20582 {
20583 return qe_invalid;
20584 }
20585
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20586 {
20587 return qe_invalid;
20588 }
20589
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20590 {
20591 return qe_invalid;
20592 }
20593
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20594 {
20595 return qe_invalid;
20596 }
20597
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.arrows,f,true))
20598 {
20599 return qe_invalid;
20600 }
20601
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20602 {
20603 return qe_invalid;
20604 }
20605
20606 29 }
20607
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if ( s_version >= 20 )
20608 {
20609
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroStep,f,true))
20610 {
20611 return qe_invalid;
20612 }
20613 29 }
20614 else
20615 {
20616 81 temp_zinit.heroStep = 150; //1.5 pixels per frame
20617 }
20618
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 81 times.
110 if ( s_version >= 21 )
20619 {
20620
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20621 {
20622 return qe_invalid;
20623 }
20624 29 }
20625 else
20626 {
20627 81 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20628 }
20629 //old only
20630
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110 if((Header->zelda_version == 0x192)&&(Header->build<174))
20631 {
20632 byte items2;
20633
20634 if(!p_getc(&items2,f,true))
20635 {
20636 return qe_invalid;
20637 }
20638
20639 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20640 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20641 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20642 }
20643
20644
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(Header->zelda_version < 0x193)
20645 {
20646 for(int32_t q=0; q<96; q++)
20647 {
20648 if(!p_getc(&padding,f,true))
20649 {
20650 return qe_invalid;
20651 }
20652 }
20653
20654 //new only
20655 if((Header->zelda_version == 0x192)&&(Header->build>173))
20656 {
20657 if(!p_getc(&padding,f,true))
20658 {
20659 return qe_invalid;
20660 }
20661
20662 if(!p_getc(&padding,f,true))
20663 {
20664 return qe_invalid;
20665 }
20666 }
20667 }
20668 110 }
20669
20670
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 61 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
166 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20671 {
20672 //temp_zinit.shield=i_smallshield;
20673
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 52 times.
61 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20674
20675
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(sshieldid != -1)
20676 9 temp_zinit.items[sshieldid] = true;
20677 9 }
20678
20679
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20680 {
20681 4 temp_zinit.hc=3;
20682 4 temp_zinit.start_heart=3;
20683 4 temp_zinit.cont_heart=3;
20684 4 temp_zinit.max_bombs=8;
20685 4 }
20686
20687
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20688 {
20689 4 sword_hearts[0]=0;
20690 4 sword_hearts[1]=5;
20691 4 sword_hearts[2]=12;
20692 4 sword_hearts[3]=21;
20693 4 }
20694
20695
3/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20696 {
20697 4 temp_zinit.last_map=0;
20698 4 temp_zinit.last_screen=0;
20699 4 }
20700
20701
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20702 {
20703 4 temp_zinit.max_magic=0;
20704 4 temp_zinit.magic=0;
20705
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20706 4 }
20707
20708
3/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20709 {
20710
20711
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20712 {
20713 16 beam_hearts[x]=100;
20714 16 }
20715
20716
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20717 {
20718
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20719
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 set_bit(quest_rules,qr_LENSHINTS+i,0);
20720 16 }
20721
20722
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t x=0; x<4; x++)
20723 {
20724
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20725 16 }
20726
20727
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20728 4 hookshot_links=100;
20729 4 temp_zinit.msg_more_x=224;
20730 4 temp_zinit.msg_more_y=64;
20731 4 }
20732
20733 // Okay, let's put these legacy values into itemsbuf.
20734
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(s_version < 15)
20735
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2304 times.
2313 for(int32_t i=0; i<MAXITEMS; i++)
20736 {
20737
11/11
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 2214 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
2304 switch(i)
20738 {
20739 case iFairyStill:
20740 9 itemsbuf[i].misc1 = stationary_fairy_hearts;
20741 9 itemsbuf[i].misc2 = stationary_fairy_magic;
20742 9 itemsbuf[i].misc3 = 0;
20743 9 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20744 9 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20745 9 break;
20746
20747 case iFairyMoving:
20748 9 itemsbuf[i].misc1 = moving_fairy_hearts;
20749 9 itemsbuf[i].misc2 = moving_fairy_magic;
20750 9 itemsbuf[i].misc3 = 50;
20751 9 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20752 9 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20753 9 break;
20754
20755 case iRPotion:
20756 9 itemsbuf[i].misc1 = red_potion_hearts;
20757 9 itemsbuf[i].misc2 = red_potion_magic;
20758 9 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20759 9 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20760 9 break;
20761
20762 case iBPotion:
20763 9 itemsbuf[i].misc1 = blue_potion_hearts;
20764 9 itemsbuf[i].misc2 = blue_potion_magic;
20765 9 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20766 9 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20767 9 break;
20768
20769 case iSword:
20770 9 itemsbuf[i].pickup_hearts = sword_hearts[0];
20771 9 itemsbuf[i].misc1 = beam_hearts[0];
20772 9 itemsbuf[i].misc2 = beam_power[0];
20773 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20774
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20775 9 break;
20776
20777 case iWSword:
20778 9 itemsbuf[i].pickup_hearts = sword_hearts[1];
20779 9 itemsbuf[i].misc1 = beam_hearts[1];
20780 9 itemsbuf[i].misc2 = beam_power[1];
20781
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20782 9 break;
20783
20784 case iMSword:
20785 9 itemsbuf[i].pickup_hearts = sword_hearts[2];
20786 9 itemsbuf[i].misc1 = beam_hearts[2];
20787 9 itemsbuf[i].misc2 = beam_power[2];
20788
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20789 9 break;
20790
20791 case iXSword:
20792 9 itemsbuf[i].pickup_hearts = sword_hearts[3];
20793 9 itemsbuf[i].misc1 = beam_hearts[3];
20794 9 itemsbuf[i].misc2 = beam_power[3];
20795
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20796 9 break;
20797
20798 case iHookshot:
20799 9 itemsbuf[i].misc1 = hookshot_length;
20800 9 itemsbuf[i].misc2 = hookshot_links;
20801 9 break;
20802
20803 case iLongshot:
20804 9 itemsbuf[i].misc1 = longshot_length;
20805 9 itemsbuf[i].misc2 = longshot_links;
20806 9 break;
20807 }
20808 2313 }
20809
20810
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20811 {
20812 //was new subscreen rule
20813
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20814
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_FREEFORM,0);
20815 4 }
20816
20817
3/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20818 {
20819 4 temp_zinit.start_dmap=0;
20820 4 }
20821
20822
3/6
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20823 {
20824
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20825 4 }
20826
20827
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
114 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20828 {
20829 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20830 temp_zinit.max_rupees=999;
20831 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20832 }
20833
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20834 {
20835 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20836 temp_zinit.max_bombs = 8;
20837 }
20838 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20839 //time to ensure that we port all new values properly:
20840
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if(Header->zelda_version < 0x250)
20841 {
20842
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20843 9 }
20844
20845
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 21)
20846 {
20847
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20848 {
20849 return qe_invalid;
20850 }
20851
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20852 {
20853 return qe_invalid;
20854 }
20855
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20856 {
20857 return qe_invalid;
20858 }
20859
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20860 {
20861 return qe_invalid;
20862 }
20863 29 }
20864 else
20865 {
20866 85 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20867 85 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20868 85 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20869 85 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20870 }
20871
20872
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 22)
20873 {
20874
2/2
✓ Branch 0 taken 725 times.
✓ Branch 1 taken 29 times.
754 for(int32_t q = 0; q < 25; ++q)
20875 {
20876
2/4
✓ Branch 0 taken 725 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 725 times.
725 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20877 {
20878 return qe_invalid;
20879 }
20880 725 }
20881
2/2
✓ Branch 0 taken 725 times.
✓ Branch 1 taken 29 times.
754 for(int32_t q = 0; q < 25; ++q)
20882 {
20883
2/4
✓ Branch 0 taken 725 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 725 times.
725 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20884 {
20885 return qe_invalid;
20886 }
20887 725 }
20888 29 }
20889 else
20890 {
20891
2/2
✓ Branch 0 taken 2125 times.
✓ Branch 1 taken 85 times.
2210 for(int32_t q = 0; q < 25; ++q)
20892 {
20893 2125 temp_zinit.scrcnt[q] = 0;
20894 2125 temp_zinit.scrmaxcnt[q] = 0;
20895 2125 }
20896 }
20897
20898
20899
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 23)
20900 {
20901
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.dither_type,f,true))
20902 {
20903 return qe_invalid;
20904 }
20905
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.dither_arg,f,true))
20906 {
20907 return qe_invalid;
20908 }
20909
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.dither_percent,f,true))
20910 {
20911 return qe_invalid;
20912 }
20913
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.def_lightrad,f,true))
20914 {
20915 return qe_invalid;
20916 }
20917
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.transdark_percent,f,true))
20918 {
20919 return qe_invalid;
20920 }
20921 29 }
20922 else
20923 {
20924 85 temp_zinit.dither_type = 0;
20925 85 temp_zinit.dither_arg = 0;
20926 85 temp_zinit.dither_percent = 20;
20927 85 temp_zinit.def_lightrad = 24;
20928 85 temp_zinit.transdark_percent = 0;
20929 }
20930
20931
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 24)
20932 {
20933
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.darkcol,f,true))
20934 {
20935 return qe_invalid;
20936 }
20937 29 }
20938 else
20939 {
20940 85 temp_zinit.darkcol = BLACK;
20941 }
20942
20943
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 25)
20944 {
20945
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.gravity2,f,true))
20946 {
20947 return qe_invalid;
20948 }
20949
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.swimgravity,f,true))
20950 {
20951 return qe_invalid;
20952 }
20953 29 }
20954 else
20955 {
20956 85 temp_zinit.gravity2 = temp_zinit.gravity*100;
20957 85 temp_zinit.swimgravity = 5;
20958 }
20959
20960
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 26)
20961 {
20962
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
20963 {
20964 return qe_invalid;
20965 }
20966
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
20967 {
20968 return qe_invalid;
20969 }
20970
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
20971 {
20972 return qe_invalid;
20973 }
20974 29 }
20975 else
20976 {
20977 85 temp_zinit.heroSideswimUpStep = 150;
20978 85 temp_zinit.heroSideswimSideStep = 100;
20979 85 temp_zinit.heroSideswimDownStep = 75;
20980 }
20981
20982
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 27)
20983 {
20984
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
20985 {
20986 return qe_invalid;
20987 }
20988 29 }
20989 else
20990 {
20991 85 temp_zinit.exitWaterJump = 0;
20992 }
20993
20994
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 29)
20995 {
20996
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
20997 {
20998 return qe_invalid;
20999 }
21000 29 }
21001 else
21002 {
21003 85 temp_zinit.bunny_ltm = 0;
21004 }
21005
21006
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 30)
21007 {
21008
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
21009 {
21010 return qe_invalid;
21011 }
21012 29 }
21013 else
21014 {
21015 85 temp_zinit.switchhookstyle = 1;
21016 }
21017
21018
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version > 31)
21019 {
21020
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
21021 {
21022 return qe_invalid;
21023 }
21024 29 }
21025 else
21026 {
21027
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
21028
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
21029 }
21030
21031
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 temp_zinit.clear_genscript();
21032
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 87 times.
114 if(s_version > 32)
21033 {
21034 27 word numgenscript = 0;
21035
2/4
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
27 if(!p_igetw(&numgenscript,f,true))
21036 return qe_invalid;
21037
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 for(auto q = 1; q < numgenscript; ++q)
21038 {
21039 if(!p_getc(&padding,f,true))
21040 return qe_invalid;
21041 if(!(padding&2))
21042 continue;
21043 temp_zinit.gen_doscript[q] = padding&1;
21044 if(!p_igetw(&temp_zinit.gen_exitState[q],f,true))
21045 return qe_invalid;
21046 if(!p_igetw(&temp_zinit.gen_reloadState[q],f,true))
21047 return qe_invalid;
21048 for(auto p = 0; p < 8; ++p)
21049 if(!p_igetl(&temp_zinit.gen_initd[q][p],f,true))
21050 return qe_invalid;
21051 if(!p_igetl(&temp_zinit.gen_dataSize[q],f,true))
21052 return qe_invalid;
21053 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f,true))
21054 return qe_invalid;
21055 if(!p_igetl(&temp_zinit.gen_eventstate[q],f,true))
21056 return qe_invalid;
21057 }
21058 27 }
21059
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 90 times.
114 if(s_version > 33)
21060 {
21061
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.hero_swim_mult,f,true))
21062 return qe_invalid;
21063
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.hero_swim_div,f,true))
21064 return qe_invalid;
21065 24 }
21066
21067
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(keepdata==true)
21068 {
21069
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 zinit = temp_zinit;
21070
21071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(zinit.heroAnimationStyle==las_zelda3slow)
21072 {
21073 hero_animation_speed=2;
21074 }
21075 else
21076 {
21077 114 hero_animation_speed=1;
21078 }
21079 114 }
21080
21081 114 return 0;
21082 438 }
21083
21084 /*
21085 void setupitemdropsets()
21086 {
21087 for(int32_t i=0; i<isMAX; i++)
21088 {
21089 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21090 }
21091 }
21092 */
21093
21094 109 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
21095 {
21096 109 build=build; // here to prevent compiler warnings
21097 dword dummy_dword;
21098 109 word item_drop_sets_to_read=0;
21099 item_drop_object tempitemdrop;
21100 109 word s_version=0, s_cversion=0;
21101
21102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata)
21103 {
21104
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21105 {
21106 27904 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21107 27904 }
21108 109 }
21109
21110
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
109 if(version > 0x192)
21111 {
21112 105 item_drop_sets_to_read=0;
21113
21114 //section version info
21115
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_version,f,true))
21116 {
21117 return qe_invalid;
21118 }
21119
21120 105 FFCore.quest_format[vItemDropsets] = s_version;
21121
21122 //al_trace("Item drop sets version %d\n", s_version);
21123
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
21124 {
21125 return qe_invalid;
21126 }
21127
21128 //section size
21129
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy_dword,f,true))
21130 {
21131 return qe_invalid;
21132 }
21133
21134 //finally... section data
21135
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&item_drop_sets_to_read,f,true))
21136 {
21137 return qe_invalid;
21138 }
21139 105 }
21140 else
21141 {
21142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
21143 {
21144 4 init_item_drop_sets();
21145 4 }
21146 }
21147
21148
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(s_version>=1)
21149 {
21150
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 105 times.
2070 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21151 {
21152
1/2
✓ Branch 0 taken 1965 times.
✗ Branch 1 not taken.
1965 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
21153 {
21154 return qe_invalid;
21155 }
21156
21157
2/2
✓ Branch 0 taken 19650 times.
✓ Branch 1 taken 1965 times.
21615 for(int32_t j=0; j<10; ++j)
21158 {
21159
1/2
✓ Branch 0 taken 19650 times.
✗ Branch 1 not taken.
19650 if(!p_igetw(&tempitemdrop.item[j],f,true))
21160 {
21161 return qe_invalid;
21162 }
21163 19650 }
21164
21165
2/2
✓ Branch 0 taken 21615 times.
✓ Branch 1 taken 1965 times.
23580 for(int32_t j=0; j<11; ++j)
21166 {
21167
1/2
✓ Branch 0 taken 21615 times.
✗ Branch 1 not taken.
21615 if(!p_igetw(&tempitemdrop.chance[j],f,true))
21168 {
21169 return qe_invalid;
21170 }
21171 21615 }
21172
21173 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21174 // overrides the quest's set #12.
21175
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1965 if(s_version<2 && i==12)
21176 continue;
21177
21178 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21179
1/4
✓ Branch 0 taken 1965 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1965 if(s_version<2) for(int32_t j=0; j<10; ++j)
21180 {
21181 int32_t it = tempitemdrop.item[j];
21182
21183 if((itemsbuf[it].family == itype_rupee
21184 && ((itemsbuf[it].amount)&0xFFF) == 10)
21185 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21186 {
21187 tempitemdrop.chance[j+1]=0;
21188 }
21189 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21190 {
21191 tempitemdrop.chance[j+1]=0;
21192 }
21193
21194 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21195 if(itemsbuf[it].family == itype_misc)
21196 {
21197 // If a non-gameplay item was selected, then item drop was aborted.
21198 // Reflect this by increasing the 'Nothing' chance accordingly.
21199 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21200 tempitemdrop.chance[j+1]=0;
21201 }
21202 }
21203
21204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(keepdata)
21205 {
21206 1965 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21207 1965 }
21208 1965 }
21209 105 }
21210
21211 109 return 0;
21212 109 }
21213
21214 105 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
21215 {
21216 int32_t temp_num;
21217 dword dummy_dword;
21218 word num_favorite_combos;
21219 word num_favorite_combo_aliases;
21220 105 word s_version=0, s_cversion=0;
21221
21222 //section version info
21223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&s_version,f,true))
21224 {
21225 return qe_invalid;
21226 }
21227
21228 105 FFCore.quest_format[vFavourites] = s_version;
21229
21230
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
21231 {
21232 return qe_invalid;
21233 }
21234
21235 //section size
21236
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy_dword,f,true))
21237 {
21238 return qe_invalid;
21239 }
21240
21241 105 word per_row = FAVORITECOMBO_PER_ROW;
21242
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 24 times.
105 if(s_version >= 3)
21243
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&per_row,f,true))
21244 return qe_invalid;
21245 //finally... section data
21246
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&num_favorite_combos,f,true))
21247 {
21248 return qe_invalid;
21249 }
21250
21251 //Hack; port old favorite combos
21252
3/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
105 if(s_version < 3 && num_favorite_combos == 100)
21253 81 per_row = 13;
21254
21255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata)
21256 {
21257
2/2
✓ Branch 0 taken 31500 times.
✓ Branch 1 taken 105 times.
31605 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21258 31500 favorite_combos[q] = -1;
21259
2/2
✓ Branch 0 taken 31500 times.
✓ Branch 1 taken 105 times.
31605 for(int q = 0; q < MAXFAVORITECOMBOALIASES; ++q)
21260 31500 favorite_comboaliases[q] = -1;
21261 105 }
21262
2/2
✓ Branch 0 taken 8628 times.
✓ Branch 1 taken 105 times.
8733 for(int32_t i=0; i<num_favorite_combos; i++)
21263 {
21264
1/2
✓ Branch 0 taken 8628 times.
✗ Branch 1 not taken.
8628 if(!p_igetl(&temp_num,f,true))
21265 {
21266 return qe_invalid;
21267 }
21268
21269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8628 times.
8628 if(keepdata)
21270 {
21271
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 8100 times.
8628 if(per_row == FAVORITECOMBO_PER_ROW)
21272 528 favorite_combos[i]=temp_num;
21273 else
21274 {
21275 8100 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21276 8100 favorite_combos[new_i]=temp_num;
21277 }
21278 8628 }
21279 8628 }
21280
21281
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21282 {
21283 return qe_invalid;
21284 }
21285
21286
2/2
✓ Branch 0 taken 8100 times.
✓ Branch 1 taken 105 times.
8205 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21287 {
21288
1/2
✓ Branch 0 taken 8100 times.
✗ Branch 1 not taken.
8100 if(!p_igetl(&temp_num,f,true))
21289 {
21290 return qe_invalid;
21291 }
21292
21293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8100 times.
8100 if(keepdata)
21294 {
21295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8100 times.
8100 if(per_row == FAVORITECOMBO_PER_ROW)
21296 favorite_comboaliases[i]=temp_num;
21297 else
21298 {
21299 8100 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21300 8100 favorite_comboaliases[new_i]=temp_num;
21301 }
21302 8100 }
21303 8100 }
21304
21305 105 word max_combo_cols = 0;
21306 105 word max_mappages = 0;
21307
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 24 times.
105 if(s_version >= 2)
21308 {
21309
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&max_combo_cols,f,true))
21310 return qe_invalid;
21311 24 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21312
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int q = 0; q < max_combo_cols; ++q)
21313 {
21314
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tmp,f,true))
21315 return qe_invalid;
21316
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tmp2,f,true))
21317 return qe_invalid;
21318
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tmp3,f,true))
21319 return qe_invalid;
21320
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
96 if(keepdata && q < MAX_COMBO_COLS)
21321 {
21322 96 First[q] = tmp;
21323 96 combo_alistpos[q] = tmp2;
21324 96 combo_pool_listpos[q] = tmp3;
21325 96 }
21326 96 }
21327
21328
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&max_mappages,f,true))
21329 return qe_invalid;
21330
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 24 times.
240 for(int q = 0; q < max_mappages; ++q)
21331 {
21332
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(!p_igetl(&tmp,f,true))
21333 return qe_invalid;
21334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_igetl(&tmp2,f,true))
21335 return qe_invalid;
21336
2/4
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 216 times.
216 if(keepdata && q < MAX_MAPPAGE_BTNS)
21337 {
21338 216 map_page[q].map = tmp;
21339 216 map_page[q].screen = tmp2;
21340 216 }
21341 216 }
21342 24 }
21343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata)
21344 {
21345
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 105 times.
429 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21346 {
21347 324 First[q] = 0;
21348 324 combo_alistpos[q] = 0;
21349 324 combo_pool_listpos[q] = 0;
21350 324 }
21351
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 105 times.
834 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21352 {
21353 729 map_page[q].map = 0;
21354 729 map_page[q].screen = 0;
21355 729 }
21356 105 }
21357
21358 105 return 0;
21359 105 }
21360
21361 /*
21362 switch (ret) {
21363 case 0:
21364 break;
21365
21366 case qe_invalid:
21367 goto invalid;
21368 break;
21369 default:
21370 pack_fclose(f);
21371 if(!oldquest)
21372 delete_file(tmpfilename);
21373 return ret;
21374 break;
21375 }
21376 */
21377
21378 const char *skip_text[skip_max]=
21379 {
21380 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21381 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21382 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21383 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21384 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21385 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21386 "skip_favorites"
21387 };
21388
21389
21390 void port250QuestRules(){
21391
21392 portCandleRules(); //Candle
21393 portBombRules();
21394
21395 }
21396
21397 void portCandleRules()
21398 {
21399 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21400 //itemdata itemsbuf;
21401 for ( int32_t q = 0; q < MAXITEMS; q++ )
21402 {
21403 if ( itemsbuf[q].family == itype_candle )
21404 {
21405 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21406 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21407 }
21408 }
21409 }
21410
21411 void portBombRules()
21412 {
21413 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21414 //itemdata itemsbuf;
21415 for ( int32_t q = 0; q < MAXITEMS; q++ )
21416 {
21417 if ( itemsbuf[q].family == itype_bomb )
21418 {
21419 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21420 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21421 }
21422 }
21423
21424 }
21425
21426 //Internal function for loadquest wrapper
21427 114 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool keepall, const byte *skip_flags, byte printmetadata)
21428 {
21429 114 DMapEditorLastMaptileUsed = 0;
21430 114 combosread=false;
21431 114 mapsread=false;
21432 114 fixffcs=false;
21433
21434
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21435 {
21436 keepall=false;
21437 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
21438 }
21439
21440 // show_progress=true;
21441 char tmpfilename[L_tmpnam];
21442 114 temp_name(tmpfilename);
21443 // char percent_done[30];
21444 114 bool catchup=false;
21445 byte tempbyte;
21446 114 word old_map_count=map_count;
21447
21448 114 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21449 114 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21450 114 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21451
21452
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(keepall==false||get_bit(skip_flags, skip_rules))
21453 {
21454 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21455 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21456 }
21457
21458 114 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21459 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21460
21461
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(keepall==false||get_bit(skip_flags, skip_midis))
21462 {
21463 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21464 }
21465
21466
21467
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21468 {
21469 114 zScript.clear();
21470 114 globalmap.clear();
21471 114 genericmap.clear();
21472 114 ffcmap.clear();
21473 114 itemmap.clear();
21474 114 npcmap.clear();
21475 114 ewpnmap.clear();
21476 114 lwpnmap.clear();
21477 114 playermap.clear();
21478 114 dmapmap.clear();
21479 114 screenmap.clear();
21480 114 itemspritemap.clear();
21481 114 comboscriptmap.clear();
21482
21483
2/2
✓ Branch 0 taken 58254 times.
✓ Branch 1 taken 114 times.
58368 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21484 {
21485 58254 ffcmap[i].clear();
21486 58254 }
21487
21488 114 globalmap[0].slotname = "Slot 1:";
21489 114 globalmap[0].scriptname = "~Init";
21490 114 globalmap[0].update();
21491
21492
2/2
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 114 times.
912 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21493 {
21494 798 globalmap[i].clear();
21495 798 }
21496
21497
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21498 {
21499 29070 itemmap[i].clear();
21500 29070 }
21501
21502 //new script types -- prevent carrying over to a quest that you load after reading them
21503 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21504
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21505 {
21506 29070 npcmap[i].clear();
21507 29070 }
21508
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21509 {
21510 29070 lwpnmap[i].clear();
21511 29070 }
21512
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21513 {
21514 29070 ewpnmap[i].clear();
21515 29070 }
21516
2/2
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 114 times.
570 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21517 {
21518 456 playermap[i].clear();
21519 456 }
21520
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21521 {
21522 29070 dmapmap[i].clear();
21523 29070 }
21524
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21525 {
21526 29070 screenmap[i].clear();
21527 29070 }
21528
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21529 {
21530 29070 itemspritemap[i].clear();
21531 29070 }
21532
2/2
✓ Branch 0 taken 58254 times.
✓ Branch 1 taken 114 times.
58368 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21533 {
21534 58254 comboscriptmap[i].clear();
21535 58254 }
21536
2/2
✓ Branch 0 taken 58254 times.
✓ Branch 1 taken 114 times.
58368 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21537 {
21538 58254 genericmap[i].clear();
21539 58254 }
21540
21541 114 reset_scripts();
21542 114 }
21543
21544 zquestheader tempheader;
21545 114 memset(&tempheader, 0, sizeof(zquestheader));
21546 114 zinfo tempzi;
21547 114 tempzi.clear();
21548 114 load_tmp_zi = &tempzi;
21549
21550 // oldquest flag is set when an unencrypted qst file is suspected.
21551 114 bool oldquest = false;
21552 114 int32_t open_error=0;
21553 114 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21554
21555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (!f)
21556 {
21557 ASSERT(open_error != 0);
21558 return open_error;
21559 }
21560 char zinfofilename[2048];
21561 114 replace_extension(zinfofilename, filename, "zinfo", 2047);
21562 114 int32_t ret=0;
21563
21564 //header
21565 114 box_out("Reading Header...");
21566 114 ret=readheader(f, &tempheader, true, printmetadata);
21567
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
114 checkstatus(ret);
21568 114 box_out("okay.");
21569 114 box_eol();
21570
21571
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
114 if(read_zinfo)
21572 {
21573 29 box_out("Reading ZInfo - ");
21574
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 28 times.
29 box_out(read_ext_zinfo ? "External..." : "Internal...");
21575
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 28 times.
29 if(read_ext_zinfo)
21576 {
21577 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21578 1 ret=readzinfo(inf, tempzi, tempheader);
21579
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21580
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21581 1 }
21582 else
21583 {
21584 28 ret=readzinfo(f, tempzi, tempheader);
21585
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
28 checkstatus(ret);
21586 }
21587 29 box_out("okay.");
21588 29 box_eol();
21589 29 }
21590
21591
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if(tempheader.zelda_version>=0x193)
21592 {
21593 dword section_id;
21594
21595 //section id
21596
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(!p_mgetl(&section_id,f,true))
21597 {
21598 return qe_invalid;
21599 }
21600
21601
2/2
✓ Branch 0 taken 2595 times.
✓ Branch 1 taken 110 times.
2705 while(!pack_feof(f))
21602 {
21603
24/25
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 110 times.
✓ Branch 6 taken 105 times.
✓ Branch 7 taken 110 times.
✓ Branch 8 taken 110 times.
✓ Branch 9 taken 110 times.
✓ Branch 10 taken 110 times.
✓ Branch 11 taken 110 times.
✓ Branch 12 taken 110 times.
✓ Branch 13 taken 105 times.
✓ Branch 14 taken 105 times.
✓ Branch 15 taken 110 times.
✓ Branch 16 taken 110 times.
✓ Branch 17 taken 105 times.
✓ Branch 18 taken 105 times.
✓ Branch 19 taken 105 times.
✓ Branch 20 taken 105 times.
✓ Branch 21 taken 110 times.
✓ Branch 22 taken 110 times.
✓ Branch 23 taken 105 times.
✓ Branch 24 taken 105 times.
2595 switch(section_id)
21604 {
21605 case ID_RULES:
21606
21607 //rules
21608
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21609 {
21610 box_out("found.");
21611 box_eol();
21612 catchup=false;
21613 }
21614
21615 110 box_out("Reading Rules...");
21616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21617
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21618 110 box_out("okay.");
21619 110 box_eol();
21620 110 break;
21621
21622 case ID_STRINGS:
21623
21624 //strings
21625
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21626 {
21627 box_out("found.");
21628 box_eol();
21629 catchup=false;
21630 }
21631
21632 110 box_out("Reading Strings...");
21633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21634
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21635 110 box_out("okay.");
21636 110 box_eol();
21637 110 break;
21638
21639 case ID_MISC:
21640
21641 //misc data
21642
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21643 {
21644 box_out("found.");
21645 box_eol();
21646 catchup=false;
21647 }
21648
21649 110 box_out("Reading Misc. Data...");
21650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21651
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21652 110 box_out("okay.");
21653 110 box_eol();
21654 110 break;
21655
21656 case ID_TILES:
21657
21658 //tiles
21659
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21660 {
21661 box_out("found.");
21662 box_eol();
21663 catchup=false;
21664 }
21665
21666 110 box_out("Reading Tiles...");
21667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21668
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21669 110 box_out("okay.");
21670 110 box_eol();
21671 110 break;
21672
21673 case ID_COMBOS:
21674
21675 //combos
21676
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21677 {
21678 box_out("found.");
21679 box_eol();
21680 catchup=false;
21681 }
21682
21683 110 box_out("Reading Combos...");
21684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21685 110 combosread=true;
21686
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21687 110 box_out("okay.");
21688 110 box_eol();
21689 110 break;
21690
21691 case ID_COMBOALIASES:
21692
21693 //combo aliases
21694
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21695 {
21696 box_out("found.");
21697 box_eol();
21698 catchup=false;
21699 }
21700
21701 105 box_out("Reading Combo Aliases...");
21702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21703
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21704 105 box_out("okay.");
21705 105 box_eol();
21706 105 break;
21707
21708 case ID_CSETS:
21709
21710 //color data
21711
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21712 {
21713 box_out("found.");
21714 box_eol();
21715 catchup=false;
21716 }
21717
21718 110 box_out("Reading Color Data...");
21719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21720
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21721 110 box_out("okay.");
21722 110 box_eol();
21723 110 break;
21724
21725 case ID_MAPS:
21726
21727 //maps
21728
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21729 {
21730 box_out("found.");
21731 box_eol();
21732 catchup=false;
21733 }
21734
21735 110 box_out("Reading Maps...");
21736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21737 110 mapsread=true;
21738
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21739 110 box_out("okay.");
21740 110 box_eol();
21741 110 break;
21742
21743 case ID_DMAPS:
21744
21745 //dmaps
21746
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21747 {
21748 box_out("found.");
21749 box_eol();
21750 catchup=false;
21751 }
21752
21753 110 box_out("Reading DMaps...");
21754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21755
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21756 110 box_out("okay.");
21757 110 box_eol();
21758 110 break;
21759
21760 case ID_DOORS:
21761
21762 //door combo sets
21763
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21764 {
21765 box_out("found.");
21766 box_eol();
21767 catchup=false;
21768 }
21769
21770 110 box_out("Reading Doors...");
21771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21772
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21773 110 box_out("okay.");
21774 110 box_eol();
21775 110 break;
21776
21777 case ID_ITEMS:
21778
21779 //items
21780
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21781 {
21782 box_out("found.");
21783 box_eol();
21784 catchup=false;
21785 }
21786
21787 110 box_out("Reading Items...");
21788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21789
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21790
21791 110 box_out("okay.");
21792 110 box_eol();
21793 110 break;
21794
21795 case ID_WEAPONS:
21796
21797 //weapons
21798
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21799 {
21800 box_out("found.");
21801 box_eol();
21802 catchup=false;
21803 }
21804
21805 110 box_out("Reading Weapons...");
21806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21807
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21808 110 box_out("okay.");
21809 110 box_eol();
21810 110 break;
21811
21812 case ID_COLORS:
21813
21814 //misc. colors
21815
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21816 {
21817 box_out("found.");
21818 box_eol();
21819 catchup=false;
21820 }
21821
21822 105 box_out("Reading Misc. Colors...");
21823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21824
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21825 105 box_out("okay.");
21826 105 box_eol();
21827 105 break;
21828
21829 case ID_ICONS:
21830
21831 //game icons
21832
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21833 {
21834 box_out("found.");
21835 box_eol();
21836 catchup=false;
21837 }
21838
21839 105 box_out("Reading Game Icons...");
21840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21841
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21842 105 box_out("okay.");
21843 105 box_eol();
21844 105 break;
21845
21846 case ID_INITDATA:
21847
21848 //initialization data
21849
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21850 {
21851 box_out("found.");
21852 box_eol();
21853 catchup=false;
21854 }
21855
21856 110 box_out("Reading Init. Data...");
21857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21858
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21859 110 box_out("okay.");
21860 110 box_eol();
21861
21862
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
110 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21863 {
21864
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 19 times.
110 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21865 {
21866 19 setupsubscreens();
21867
21868
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 19 times.
9747 for(int32_t i=0; i<MAXDMAPS; ++i)
21869 {
21870 9728 int32_t type=DMaps[i].type&dmfTYPE;
21871
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 9634 times.
9728 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21872 9728 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21873 9728 }
21874 19 }
21875 110 }
21876
21877
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
110 if(keepall&&!get_bit(skip_flags, skip_sfx))
21878 {
21879 110 setupsfx();
21880 110 }
21881
21882
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
110 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
21883 {
21884 110 init_item_drop_sets();
21885 110 }
21886
21887
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
110 if(keepall&&!get_bit(skip_flags, skip_favorites))
21888 {
21889 110 init_favorites();
21890 110 }
21891
21892 110 break;
21893
21894 case ID_GUYS:
21895
21896 //guys
21897
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21898 {
21899 box_out("found.");
21900 box_eol();
21901 catchup=false;
21902 }
21903
21904 110 box_out("Reading Custom Guy Data...");
21905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21906
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21907 110 box_out("okay.");
21908 110 box_eol();
21909 110 break;
21910
21911 case ID_HEROSPRITES:
21912
21913 //player sprites
21914
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21915 {
21916 box_out("found.");
21917 box_eol();
21918 catchup=false;
21919 }
21920
21921 105 box_out("Reading Custom Player Sprite Data...");
21922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
21923
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21924 105 box_out("okay.");
21925 105 box_eol();
21926 105 break;
21927
21928 case ID_SUBSCREEN:
21929
21930 //custom subscreens
21931
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21932 {
21933 box_out("found.");
21934 box_eol();
21935 catchup=false;
21936 }
21937
21938 105 box_out("Reading Custom Subscreen Data...");
21939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
21940
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21941 105 box_out("okay.");
21942 105 box_eol();
21943 105 break;
21944
21945 case ID_FFSCRIPT:
21946
21947 //Freeform combo scripts
21948
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21949 {
21950 box_out("found.");
21951 box_eol();
21952 catchup=false;
21953 }
21954
21955 105 box_out("Reading FF Script Data...");
21956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
21957
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21958 105 box_out("okay.");
21959 105 box_eol();
21960 105 break;
21961
21962 case ID_SFX:
21963
21964 //SFX data
21965
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21966 {
21967 box_out("found.");
21968 box_eol();
21969 catchup=false;
21970 }
21971
21972 105 box_out("Reading SFX Data...");
21973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
21974
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21975 105 box_out("okay.");
21976 105 box_eol();
21977 105 break;
21978
21979 case ID_MIDIS:
21980
21981 //midis
21982
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
21983 {
21984 box_out("found.");
21985 box_eol();
21986 catchup=false;
21987 }
21988
21989 110 box_out("Reading Tunes...");
21990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21991
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
21992 110 box_out("okay.");
21993 110 box_eol();
21994 110 break;
21995
21996 case ID_CHEATS:
21997
21998 //cheat codes
21999
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(catchup)
22000 {
22001 box_out("found.");
22002 box_eol();
22003 catchup=false;
22004 }
22005
22006 110 box_out("Reading Cheat Codes...");
22007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22008
1/5
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
110 checkstatus(ret);
22009 110 box_out("okay.");
22010 110 box_eol();
22011 110 break;
22012
22013 case ID_ITEMDROPSETS:
22014
22015 //item drop sets
22016
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
22017 {
22018 box_out("found.");
22019 box_eol();
22020 catchup=false;
22021 }
22022
22023 105 box_out("Reading Item Drop Sets...");
22024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22025
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
22026 105 box_out("okay.");
22027 105 box_eol();
22028 105 break;
22029
22030 case ID_FAVORITES:
22031
22032 //favorite combos and combo aliases
22033
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
22034 {
22035 box_out("found.");
22036 box_eol();
22037 catchup=false;
22038 }
22039
22040 105 box_out("Reading Favorite Combos...");
22041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
22042
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
22043 105 box_out("okay.");
22044 105 box_eol();
22045 105 break;
22046
22047 default:
22048 if(!catchup)
22049 {
22050 box_out("Bad token! Searching...");
22051 box_eol();
22052 }
22053
22054 catchup=true;
22055 break;
22056 }
22057
22058
22059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2595 times.
2595 if(catchup)
22060 {
22061 //section id
22062 section_id=(section_id<<8);
22063
22064 if(!p_getc(&tempbyte,f,true))
22065 {
22066 return qe_invalid;
22067 }
22068
22069 section_id+=tempbyte;
22070 }
22071
22072 else
22073 {
22074 //section id
22075
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 2485 times.
2595 if(!pack_feof(f))
22076 {
22077
1/2
✓ Branch 0 taken 2485 times.
✗ Branch 1 not taken.
2485 if(!p_mgetl(&section_id,f,true))
22078 {
22079 return qe_invalid;
22080 }
22081 2485 }
22082 }
22083 }
22084 110 }
22085 else
22086 {
22087 //rules
22088 4 box_out("Reading Rules...");
22089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
22090
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22091 4 box_out("okay.");
22092 4 box_eol();
22093
22094 //strings
22095 4 box_out("Reading Strings...");
22096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
22097
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22098 4 box_out("okay.");
22099 4 box_eol();
22100
22101 //door combo sets
22102 4 box_out("Reading Doors...");
22103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
22104
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22105 4 box_out("okay.");
22106 4 box_eol();
22107
22108 //dmaps
22109 4 box_out("Reading DMaps...");
22110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
22111
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22112 4 box_out("okay.");
22113 4 box_eol();
22114
22115 // misc data
22116 4 box_out("Reading Misc. Data...");
22117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
22118
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22119 4 box_out("okay.");
22120 4 box_eol();
22121
22122 //items
22123 4 box_out("Reading Items...");
22124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
22125
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22126 4 box_out("okay.");
22127 4 box_eol();
22128
22129 //weapons
22130 4 box_out("Reading Weapons...");
22131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
22132
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22133 4 box_out("okay.");
22134 4 box_eol();
22135
22136 //guys
22137 4 box_out("Reading Custom Guy Data...");
22138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
22139
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22140 4 box_out("okay.");
22141 4 box_eol();
22142
22143 //maps
22144 4 box_out("Reading Maps...");
22145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
22146 4 mapsread=true;
22147
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22148 4 box_out("okay.");
22149 4 box_eol();
22150
22151 //combos
22152 4 box_out("Reading Combos...");
22153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
22154 4 combosread=true;
22155
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22156 4 box_out("okay.");
22157 4 box_eol();
22158
22159 //color data
22160 4 box_out("Reading Color Data...");
22161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
22162
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22163 4 box_out("okay.");
22164 4 box_eol();
22165
22166 //tiles
22167 4 box_out("Reading Tiles...");
22168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
22169
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22170 4 box_out("okay.");
22171 4 box_eol();
22172
22173 //midis
22174 4 box_out("Reading Tunes...");
22175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
22176
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22177 4 box_out("okay.");
22178 4 box_eol();
22179
22180 //cheat codes
22181 4 box_out("Reading Cheat Codes...");
22182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22183
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22184 4 box_out("okay.");
22185 4 box_eol();
22186
22187 //initialization data
22188 4 box_out("Reading Init. Data...");
22189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
22190
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22191 4 box_out("okay.");
22192 4 box_eol();
22193
22194
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepall&&!get_bit(skip_flags, skip_subscreens))
22195 {
22196 4 setupsubscreens();
22197
22198
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22199 {
22200 2048 int32_t type=DMaps[i].type&dmfTYPE;
22201
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22202 2048 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
22203 2048 }
22204 4 }
22205
22206 4 box_out("Setting Up Default Sound Effects...");
22207
22208
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepall&&!get_bit(skip_flags, skip_sfx))
22209 4 setupsfx();
22210
22211 4 box_out("okay.");
22212 4 box_eol();
22213
22214 //player sprites
22215 4 box_out("Reading Custom Player Sprite Data...");
22216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
22217
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22218 4 box_out("okay.");
22219 4 box_eol();
22220
22221 4 box_out("Setting Up Default Item Drop Sets...");
22222
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22223 4 box_out("okay.");
22224 4 box_eol();
22225 }
22226
22227 114 init_spritelists();
22228
22229 // check data
22230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(f)
22231 {
22232 114 pack_fclose(f);
22233 114 }
22234 114 clear_quest_tmpfile();
22235
22236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!oldquest)
22237 {
22238
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(exists(tmpfilename))
22239 {
22240 delete_file(tmpfilename);
22241 }
22242 114 }
22243
22244
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if(fixffcs && combosread && mapsread)
22245 {
22246 for(int32_t i=0; i<map_count; i++)
22247 {
22248 for(int32_t j=0; j<MAPSCRS; j++)
22249 {
22250 for(int32_t m=0; m<32; m++)
22251 {
22252 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22253 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22254 }
22255 }
22256 }
22257 }
22258
22259
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 22 times.
114 if(get_bit(quest_rules, qr_CONTFULL_DEP))
22260 {
22261 22 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
22262 22 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22263 22 zinit.cont_heart=100;
22264 22 zinit.start_heart=zinit.hc;
22265 22 }
22266
22267 114 box_out("Done.");
22268 114 box_eol();
22269 114 box_end(false);
22270
22271 // if (keepall==true||!get_bit(skip_flags, skip_header))
22272
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(keepall&&!get_bit(skip_flags, skip_header))
22273 {
22274 114 memcpy(Header, &tempheader, sizeof(tempheader));
22275 114 }
22276
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(keepall&&!get_bit(skip_flags, skip_zinfo))
22277 {
22278 114 ZI.copyFrom(tempzi);
22279 114 }
22280
22281
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(!keepall||get_bit(skip_flags, skip_maps))
22282 {
22283 map_count=old_map_count;
22284 }
22285
22286
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(!keepall||get_bit(skip_flags, skip_rules))
22287 {
22288 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22289 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22290 }
22291
22292
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if(!keepall||get_bit(skip_flags, skip_midis))
22293 {
22294 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22295 }
22296
22297 //Debug FFCore.quest_format[]
22298 114 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22299 114 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22300 114 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22301 114 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22302 114 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22303 114 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22304 114 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22305 114 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22306 114 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22307 114 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22308 114 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22309 114 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22310 114 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22311 114 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22312 114 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22313 114 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22314 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22315 114 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22316 114 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22317 114 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22318 114 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22319 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22320 114 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22321 114 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22322 114 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22323 114 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22324 114 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22325 114 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22326 114 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22327 114 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22328 //Print metadata for versions under 2.10 here. Bleah.
22329
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if( FFCore.quest_format[vZelda] < 0x210 )
22330 {
22331 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22332
22333
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22334 {
22335 case 0x193:
22336 {
22337 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22338 }
22339 case 0x192:
22340 {
22341 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22342 }
22343 case 0x190:
22344 {
22345 4 zprint2("Last saved in ZC Editor Version: 1.90");
22346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22347 4 else zprint2("\n");
22348 4 break;
22349 }
22350 case 0x188:
22351 {
22352 zprint2("Last saved in ZC Editor Version: 1.88");
22353 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22354 else zprint2("\n");
22355 break;
22356 }
22357 case 0x187:
22358 {
22359 zprint2("Last saved in ZC Editor Version: 1.87");
22360 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22361 else zprint2("\n");
22362 break;
22363 }
22364 case 0x186:
22365 {
22366 zprint2("Last saved in ZC Editor Version: 1.86");
22367 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22368 else zprint2("\n");
22369 break;
22370 }
22371 case 0x185:
22372 {
22373 zprint2("Last saved in ZC Editor Version: 1.85");
22374 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22375 else zprint2("\n");
22376 break;
22377 }
22378 case 0x184:
22379 {
22380 zprint2("Last saved in ZC Editor Version: 1.84");
22381 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22382 else zprint2("\n");
22383 break;
22384 }
22385 case 0x183:
22386 {
22387 zprint2("Last saved in ZC Editor Version: 1.83");
22388 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22389 else zprint2("\n");
22390 break;
22391 }
22392 case 0x182:
22393 {
22394 zprint2("Last saved in ZC Editor Version: 1.82");
22395 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22396 else zprint2("\n");
22397 break;
22398 }
22399 case 0x181:
22400 {
22401 zprint2("Last saved in ZC Editor Version: 1.81");
22402 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22403 else zprint2("\n");
22404 break;
22405 }
22406 case 0x180:
22407 {
22408 zprint2("Last saved in ZC Editor Version: 1.80");
22409 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22410 else zprint2("\n");
22411 break;
22412 }
22413 default:
22414 {
22415 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22416 }
22417 }
22418 4 }
22419
22420 114 return qe_OK;
22421
22422 invalid:
22423 box_out("error.");
22424 box_eol();
22425 box_end(true);
22426
22427 if(f)
22428 {
22429 pack_fclose(f);
22430 }
22431
22432 if(!oldquest)
22433 {
22434 if(exists(tmpfilename))
22435 {
22436 delete_file(tmpfilename);
22437 }
22438 }
22439
22440 return qe_invalid;
22441
22442 114 }
22443
22444 114 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22445 {
22446 114 loading_qst_name = filename;
22447 114 loading_qst_num = qst_num;
22448 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22449 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22450
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if (!is_ci())
22451 loadquest_report = report;
22452 114 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, keepall, skip_flags,printmetadata);
22453 114 load_tmp_zi = NULL;
22454 114 loading_qst_name = NULL;
22455 114 loadquest_report = false;
22456 114 loading_qst_num = 0;
22457 114 return ret;
22458 }
22459